129 $this->templateVariableContainer = $renderingContext->getTemplateVariableContainer();
130 if ($renderingContext->getControllerContext() !== NULL) {
131 $this->controllerContext = $renderingContext->getControllerContext();
133 $this->viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
169 protected function registerArgument($name, $type, $description, $required = FALSE, $defaultValue = NULL) {
170 if (array_key_exists($name, $this->argumentDefinitions)) {
171 throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception(
'Argument "' . $name .
'" has already been defined, thus it should not be defined again.', 1253036401);
173 $this->argumentDefinitions[$name] = new \TYPO3\CMS\Fluid\Core\ViewHelper\ArgumentDefinition($name, $type, $description, $required, $defaultValue);
191 protected function overrideArgument($name, $type, $description, $required = FALSE, $defaultValue = NULL) {
192 if (!array_key_exists($name, $this->argumentDefinitions)) {
193 throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception(
'Argument "' . $name .
'" has not been defined, thus it can\'t be overridden.', 1279212461);
195 $this->argumentDefinitions[$name] = new \TYPO3\CMS\Fluid\Core\ViewHelper\ArgumentDefinition($name, $type, $description, $required, $defaultValue);
208 $this->viewHelperNode = $node;
240 $renderMethodParameters = array();
241 foreach ($this->argumentDefinitions as $argumentName => $argumentDefinition) {
242 if ($argumentDefinition->isMethodParameter()) {
243 $renderMethodParameters[$argumentName] = $this->arguments[$argumentName];
248 return call_user_func_array(array($this,
'render'), $renderMethodParameters);
251 return $exception->getMessage();
274 if ($this->renderChildrenClosure !== NULL) {
278 return $this->viewHelperNode->evaluateChildNodes($this->renderingContext);
291 return function () use ($self) {
292 return $self->renderChildren();
302 if (!$this->argumentsInitialized) {
303 $thisClassName = get_class($this);
304 if (isset(self::$argumentDefinitionCache[$thisClassName])) {
305 $this->argumentDefinitions = self::$argumentDefinitionCache[$thisClassName];
311 $this->argumentsInitialized = TRUE;
323 $methodParameters = $this->reflectionService->getMethodParameters(get_class($this),
'render');
324 if (count($methodParameters) === 0) {
329 $methodTags = $this->reflectionService->getMethodTagsValues(get_class($this),
'render');
331 $paramAnnotations = array();
332 if (isset($methodTags[
'param'])) {
333 $paramAnnotations = $methodTags[
'param'];
338 foreach ($methodParameters as $parameterName => $parameterInfo) {
340 if (isset($parameterInfo[
'type'])) {
341 $dataType = $parameterInfo[
'type'];
342 } elseif ($parameterInfo[
'array']) {
345 if ($dataType === NULL) {
346 throw new \TYPO3\CMS\Fluid\Core\Parser\Exception(
'could not determine type of argument "' . $parameterName .
'" of the render-method in ViewHelper "' . get_class($this) .
'". Either the methods docComment is invalid or some PHP optimizer strips off comments.', 1242292003);
350 if (\
TYPO3\CMS\
Fluid\Fluid::$debugMode && isset($paramAnnotations[$i])) {
351 $explodedAnnotation = explode(
' ', $paramAnnotations[$i]);
352 array_shift($explodedAnnotation);
353 array_shift($explodedAnnotation);
354 $description = implode(
' ', $explodedAnnotation);
356 $defaultValue = NULL;
357 if (isset($parameterInfo[
'defaultValue'])) {
358 $defaultValue = $parameterInfo[
'defaultValue'];
360 $this->argumentDefinitions[$parameterName] = new \TYPO3\CMS\Fluid\Core\ViewHelper\ArgumentDefinition($parameterName, $dataType, $description, ($parameterInfo[
'optional'] === FALSE), $defaultValue, TRUE);
378 if ($this->arguments[$argumentName] === $registeredArgument->getDefaultValue()) {
382 $type = $registeredArgument->getType();
383 if ($type ===
'array') {
384 if (!is_array($this->arguments[$argumentName]) && !$this->arguments[$argumentName] instanceof \ArrayAccess && !$this->arguments[$argumentName] instanceof \Traversable) {
385 throw new \InvalidArgumentException(
'The argument "' . $argumentName .
'" was registered with type "array", but is of type "' . gettype($this->arguments[$argumentName]) .
'" in view helper "' . get_class($this) .
'"', 1237900529);
387 } elseif ($type ===
'boolean') {
388 if (!is_bool($this->arguments[$argumentName])) {
389 throw new \InvalidArgumentException(
'The argument "' . $argumentName .
'" was registered with type "boolean", but is of type "' . gettype($this->arguments[$argumentName]) .
'" in view helper "' . get_class($this) .
'".', 1240227732);
391 } elseif (class_exists($type, FALSE)) {
392 if (!($this->arguments[$argumentName] instanceof $type)) {
393 if (is_object($this->arguments[$argumentName])) {
394 throw new \InvalidArgumentException(
'The argument "' . $argumentName .
'" was registered with type "' . $type .
'", but is of type "' . get_class($this->arguments[$argumentName]) .
'" in view helper "' . get_class($this) .
'".', 1256475114);
396 throw new \InvalidArgumentException(
'The argument "' . $argumentName .
'" was registered with type "' . $type .
'", but is of type "' . gettype($this->arguments[$argumentName]) .
'" in view helper "' . get_class($this) .
'".', 1256475113);
433 return isset($this->arguments[$argumentName]) && $this->arguments[$argumentName] !== NULL;
452 public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \
TYPO3\CMS\
Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \
TYPO3\CMS\
Fluid\Core\Compiler\TemplateCompiler $templateCompiler) {
453 return sprintf(
'%s::renderStatic(%s, %s, $renderingContext)',
454 get_class($this), $argumentsVariableName, $renderChildrenClosureVariableName);
hasArgument($argumentName)
$templateVariableContainer
initializeArgumentsAndRender()
registerArgument($name, $type, $description, $required=FALSE, $defaultValue=NULL)
setArguments(array $arguments)
registerRenderMethodArguments()
injectReflectionService(\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
$viewHelperVariableContainer
overrideArgument($name, $type, $description, $required=FALSE, $defaultValue=NULL)
setViewHelperNode(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $node)
isEscapingInterceptorEnabled()
setRenderingContext(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
setRenderChildrenClosure(\Closure $renderChildrenClosure)
compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
static $argumentDefinitionCache
static renderStatic(array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
$escapingInterceptorEnabled
buildRenderChildrenClosure()