TYPO3 CMS  TYPO3_6-2
NameAttribute.php
Go to the documentation of this file.
1 <?php
3 
23 
29  protected $addition;
30 
36  protected $returnValueWithoutPrefix = FALSE;
37 
43  public function getValueWithoutPrefix() {
44  $value = (string) $this->value;
45  // Change spaces into hyphens
46  $value = preg_replace('/\\s/', '-', $value);
47  // Remove non-word characters
48  $value = preg_replace('/[^a-zA-Z0-9_\\-]+/', '', $value);
49  if (empty($value)) {
51  }
52  return $value;
53  }
54 
69  public function getValue() {
70  $value = $this->getValueWithoutPrefix();
71  if ($this->returnValueWithoutPrefix === FALSE) {
72  $requestHandler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Request');
73  $attribute = $requestHandler->getPrefix() . '[' . $value . ']' . $this->addition;
74  } else {
75  $attribute = $value;
76  }
77  return $attribute;
78  }
79 
87  public function setAddition($addition) {
88  $this->addition = (string) $addition;
89  return $this;
90  }
91 
99  public function setReturnValueWithoutPrefix($parameter) {
100  $this->returnValueWithoutPrefix = (bool) $parameter;
101  }
102 
103 }