1 | <?php |
||
21 | class ViewHelperNode extends AbstractNode |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $viewHelperClassName; |
||
28 | |||
29 | /** |
||
30 | * @var NodeInterface[] |
||
31 | */ |
||
32 | protected $arguments = []; |
||
33 | |||
34 | /** |
||
35 | * @var ViewHelperInterface |
||
36 | */ |
||
37 | protected $uninitializedViewHelper = null; |
||
38 | |||
39 | /** |
||
40 | * @var ArgumentDefinition[] |
||
41 | */ |
||
42 | protected $argumentDefinitions = []; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $pointerTemplateCode = null; |
||
48 | |||
49 | /** |
||
50 | * @var ParsingState |
||
51 | */ |
||
52 | protected $parsingState; |
||
53 | |||
54 | /** |
||
55 | * Constructor. |
||
56 | * |
||
57 | * @param RenderingContextInterface $renderingContext a RenderingContext, provided by invoker |
||
58 | * @param string $namespace the namespace identifier of the ViewHelper. |
||
59 | * @param string $identifier the name of the ViewHelper to render, inside the namespace provided. |
||
60 | * @param NodeInterface[] $arguments Arguments of view helper - each value is a RootNode. |
||
61 | * @param ParsingState $state |
||
62 | */ |
||
63 | public function __construct( |
||
82 | |||
83 | /** |
||
84 | * @return ArgumentDefinition[] |
||
85 | */ |
||
86 | public function getArgumentDefinitions() |
||
90 | |||
91 | /** |
||
92 | * Returns the attached (but still uninitialized) ViewHelper for this ViewHelperNode. |
||
93 | * We need this method because sometimes Interceptors need to ask some information from the ViewHelper. |
||
94 | * |
||
95 | * @return ViewHelperInterface |
||
96 | */ |
||
97 | public function getUninitializedViewHelper() |
||
101 | |||
102 | /** |
||
103 | * Get class name of view helper |
||
104 | * |
||
105 | * @return string Class Name of associated view helper |
||
106 | */ |
||
107 | public function getViewHelperClassName() |
||
111 | |||
112 | /** |
||
113 | * INTERNAL - only needed for compiling templates |
||
114 | * |
||
115 | * @return NodeInterface[] |
||
116 | */ |
||
117 | public function getArguments() |
||
121 | |||
122 | /** |
||
123 | * INTERNAL - only needed for compiling templates |
||
124 | * |
||
125 | * @param string $argumentName |
||
126 | * @return ArgumentDefinition |
||
127 | */ |
||
128 | public function getArgumentDefinition($argumentName) |
||
132 | |||
133 | /** |
||
134 | * @param NodeInterface $childNode |
||
135 | * @return void |
||
136 | */ |
||
137 | public function addChildNode(NodeInterface $childNode) |
||
142 | |||
143 | /** |
||
144 | * @param string $pointerTemplateCode |
||
145 | * @return void |
||
146 | */ |
||
147 | public function setPointerTemplateCode($pointerTemplateCode) |
||
151 | |||
152 | /** |
||
153 | * Call the view helper associated with this object. |
||
154 | * |
||
155 | * First, it evaluates the arguments of the view helper. |
||
156 | * |
||
157 | * If the view helper implements \TYPO3Fluid\Fluid\Core\ViewHelper\ChildNodeAccessInterface, |
||
158 | * it calls setChildNodes(array childNodes) on the view helper. |
||
159 | * |
||
160 | * Afterwards, checks that the view helper did not leave a variable lying around. |
||
161 | * |
||
162 | * @param RenderingContextInterface $renderingContext |
||
163 | * @return string evaluated node after the view helper has been called. |
||
164 | */ |
||
165 | public function evaluate(RenderingContextInterface $renderingContext) |
||
170 | |||
171 | /** |
||
172 | * Wraps the argument tree, if a node is boolean, into a Boolean syntax tree node |
||
173 | * |
||
174 | * @param ArgumentDefinition[] $argumentDefinitions the argument definitions, key is the argument name, value is the ArgumentDefinition object |
||
175 | * @param NodeInterface[] $argumentsObjectTree the arguments syntax tree, key is the argument name, value is an AbstractNode |
||
176 | * @return void |
||
177 | */ |
||
178 | protected function rewriteBooleanNodesInArgumentsObjectTree($argumentDefinitions, &$argumentsObjectTree) |
||
189 | |||
190 | /** |
||
191 | * Call interceptors for viewHelper arguments |
||
192 | * |
||
193 | * @param TemplateParser $templateParser |
||
194 | * @return void |
||
195 | */ |
||
196 | public function callArgumentInterceptors(TemplateParser $templateParser) |
||
210 | |||
211 | /** |
||
212 | * @param ArgumentDefinition[] $argumentDefinitions |
||
213 | * @param NodeInterface[] $argumentsObjectTree |
||
214 | * @throws Exception |
||
215 | */ |
||
216 | protected function validateArguments(array $argumentDefinitions, array $argumentsObjectTree) |
||
236 | |||
237 | /** |
||
238 | * Throw an exception if required arguments are missing |
||
239 | * |
||
240 | * @param ArgumentDefinition[] $expectedArguments Array of all expected arguments |
||
241 | * @param NodeInterface[] $actualArguments Actual arguments |
||
242 | * @throws Exception |
||
243 | */ |
||
244 | protected function abortIfRequiredArgumentsAreMissing($expectedArguments, $actualArguments) |
||
254 | } |
||
255 |