2 namespace TYPO3\CMS\Fluid\Core\ViewHelper;
47 $this->variables = $variableArray;
59 public function add($identifier, $value)
61 if (array_key_exists($identifier, $this->variables)) {
62 throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException(
'Duplicate variable declaration, "' . $identifier .
'" already set!', 1224479063);
64 if (in_array(strtolower($identifier), self::$reservedVariableNames)) {
65 throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException(
'"' . $identifier .
'" is a reserved variable name and cannot be used as variable identifier.', 1256730379);
67 $this->variables[$identifier] = $value;
80 public function get($identifier)
82 if ($identifier ===
'_all') {
85 if (!array_key_exists($identifier, $this->variables)) {
86 throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException(
'Tried to get a variable "' . $identifier .
'" which is not stored in the context!', 1224479370);
88 return $this->variables[$identifier];
99 public function remove($identifier)
101 if (!array_key_exists($identifier, $this->variables)) {
102 throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException(
'Tried to remove a variable "' . $identifier .
'" which is not stored in the context!', 1224479372);
104 unset($this->variables[$identifier]);
114 return array_keys($this->variables);
136 if ($identifier ===
'_all') {
140 return array_key_exists($identifier, $this->variables);
150 return array(
'variables');
162 $this->
add($identifier, $value);
173 $this->
remove($identifier);
184 return $this->
exists($identifier);
195 return $this->
get($identifier);
207 if ($variableName ===
'_all') {
211 return isset($this->variables[$variableName]) ? $this->variables[$variableName] : null;