1 | <?php |
||
17 | class ViewHelperVariableContainer |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Two-dimensional object array storing the values. The first dimension is the fully qualified ViewHelper name, |
||
22 | * and the second dimension is the identifier for the data the ViewHelper wants to store. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $objects = []; |
||
27 | |||
28 | /** |
||
29 | * @var ViewInterface |
||
30 | */ |
||
31 | protected $view; |
||
32 | |||
33 | /** |
||
34 | * @var VariableProviderInterface[] |
||
35 | */ |
||
36 | protected $delegates = []; |
||
37 | |||
38 | /** |
||
39 | * Push a new delegate variable container to a stack. |
||
40 | * |
||
41 | * If a ViewHelper requires a storage to collect variables which, for |
||
42 | * example, are filled by evaluating the child (tag content) closure, |
||
43 | * this method can be used to add a special delegate variable container |
||
44 | * stored in a stack. Once the variables you need to collect have been |
||
45 | * collected, calling `popDelegateVariableProvider` removes the delegate |
||
46 | * from the stack. |
||
47 | * |
||
48 | * The point of a stack is to avoid resetting a storage every time a |
||
49 | * ViewHelper is rendered. In the case of `f:render` it means one storage |
||
50 | * is created and filled for every one call to the ViewHelper. |
||
51 | * |
||
52 | * It is VITAL that you also "pop" any delegate you push to this stack! |
||
53 | * |
||
54 | * @param VariableProviderInterface $variableProvider |
||
55 | */ |
||
56 | public function pushDelegateVariableProvider(VariableProviderInterface $variableProvider) |
||
60 | |||
61 | /** |
||
62 | * Get the topmost delegate variable container that was previously pushed |
||
63 | * onto the stack by pushDelegateVariableContainer(). This method returns |
||
64 | * a reference to the storage that was last added to the stack without |
||
65 | * removing the variable provider from the stack. |
||
66 | * |
||
67 | * Is used in ViewHelpers that assign variables in variable providers in |
||
68 | * the stack - as a means to get the variable storage used by the "closest |
||
69 | * parent", e.g. when called in `f:argument` used inside `f:render`, will |
||
70 | * read the delegate variable provider inserted by that parent `f:render`. |
||
71 | * |
||
72 | * @return VariableProviderInterface|null |
||
73 | */ |
||
74 | public function getTopmostDelegateVariableProvider() |
||
78 | |||
79 | /** |
||
80 | * Return and REMOVE the topmost delegate variable provider. This method |
||
81 | * must be called after you finish sub-rendering with a delegated variable |
||
82 | * provider that was added with `pushDelegateVariableProvider`. Calling |
||
83 | * the method removes the delegate and returns the stack to the previous |
||
84 | * state it was in. |
||
85 | * |
||
86 | * To avoid removing from the stack, use `getTopmostDelegateVariableProvider`. |
||
87 | * |
||
88 | * @param string $viewHelperClassName |
||
|
|||
89 | * @return VariableProviderInterface|null |
||
90 | */ |
||
91 | public function popDelegateVariableProvider() |
||
95 | |||
96 | /** |
||
97 | * Add a variable to the Variable Container. Make sure that $viewHelperName is ALWAYS set |
||
98 | * to your fully qualified ViewHelper Class Name |
||
99 | * |
||
100 | * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper") |
||
101 | * @param string $key Key of the data |
||
102 | * @param mixed $value The value to store |
||
103 | * @return void |
||
104 | * @api |
||
105 | */ |
||
106 | public function add($viewHelperName, $key, $value) |
||
110 | |||
111 | /** |
||
112 | * Adds, or overrides recursively, all current variables defined in associative |
||
113 | * array or Traversable (with string keys!). |
||
114 | * |
||
115 | * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper") |
||
116 | * @param array|\Traversable $variables An associative array of all variables to add |
||
117 | * @return void |
||
118 | * @api |
||
119 | */ |
||
120 | public function addAll($viewHelperName, $variables) |
||
134 | |||
135 | /** |
||
136 | * Add a variable to the Variable Container. Make sure that $viewHelperName is ALWAYS set |
||
137 | * to your fully qualified ViewHelper Class Name. |
||
138 | * In case the value is already inside, it is silently overridden. |
||
139 | * |
||
140 | * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper") |
||
141 | * @param string $key Key of the data |
||
142 | * @param mixed $value The value to store |
||
143 | * @return void |
||
144 | */ |
||
145 | public function addOrUpdate($viewHelperName, $key, $value) |
||
152 | |||
153 | /** |
||
154 | * Gets a variable which is stored |
||
155 | * |
||
156 | * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper") |
||
157 | * @param string $key Key of the data |
||
158 | * @param mixed $default Default value to use if no value is found. |
||
159 | * @return mixed The object stored |
||
160 | * @api |
||
161 | */ |
||
162 | public function get($viewHelperName, $key, $default = null) |
||
166 | |||
167 | /** |
||
168 | * Gets all variables stored for a particular ViewHelper |
||
169 | * |
||
170 | * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper") |
||
171 | * @param mixed $default |
||
172 | * @return array |
||
173 | */ |
||
174 | public function getAll($viewHelperName, $default = null) |
||
178 | |||
179 | /** |
||
180 | * Determine whether there is a variable stored for the given key |
||
181 | * |
||
182 | * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper") |
||
183 | * @param string $key Key of the data |
||
184 | * @return boolean TRUE if a value for the given ViewHelperName / Key is stored, FALSE otherwise. |
||
185 | * @api |
||
186 | */ |
||
187 | public function exists($viewHelperName, $key) |
||
191 | |||
192 | /** |
||
193 | * Remove a value from the variable container |
||
194 | * |
||
195 | * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper") |
||
196 | * @param string $key Key of the data to remove |
||
197 | * @return void |
||
198 | * @api |
||
199 | */ |
||
200 | public function remove($viewHelperName, $key) |
||
204 | |||
205 | /** |
||
206 | * Set the view to pass it to ViewHelpers. |
||
207 | * |
||
208 | * @param ViewInterface $view View to set |
||
209 | * @return void |
||
210 | */ |
||
211 | public function setView(ViewInterface $view) |
||
215 | |||
216 | /** |
||
217 | * Get the view. |
||
218 | * |
||
219 | * !!! This is NOT a public API and might still change!!! |
||
220 | * |
||
221 | * @return ViewInterface The View |
||
222 | */ |
||
223 | public function getView() |
||
227 | |||
228 | /** |
||
229 | * Clean up for serializing. |
||
230 | * |
||
231 | * @return array |
||
232 | */ |
||
233 | public function __sleep() |
||
237 | } |
||
238 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.