TYPO3
7.6
|
Static Public Member Functions | |
static | renderStatic (array $arguments,\Closure $renderChildrenClosure,\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext) |
Static Public Member Functions inherited from AbstractViewHelper | |
static | renderStatic (array $arguments,\Closure $renderChildrenClosure,\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext) |
Protected Member Functions | |
renderThenChild () | |
renderElseChild () | |
Protected Member Functions inherited from AbstractViewHelper | |
registerArgument ($name, $type, $description, $required=false, $defaultValue=null) | |
overrideArgument ($name, $type, $description, $required=false, $defaultValue=null) | |
callRenderMethod () | |
getLogger () | |
buildRenderChildrenClosure () | |
hasArgument ($argumentName) | |
Static Protected Member Functions | |
static | renderStaticThenChild ($arguments, &$hasEvaluated) |
static | renderStaticElseChild ($arguments, &$hasEvaluated) |
static | evaluateCondition ($arguments=null) |
Private Attributes | |
$childNodes = array() | |
Additional Inherited Members | |
Protected Attributes inherited from AbstractViewHelper | |
$arguments | |
$templateVariableContainer | |
$controllerContext | |
$renderingContext | |
$renderChildrenClosure = null | |
$viewHelperVariableContainer | |
$objectManager | |
$escapingInterceptorEnabled = true | |
This view helper is an abstract ViewHelper which implements an if/else condition.
= Usage =
To create a custom Condition ViewHelper, you need to subclass this class, and implement your own render() method. Inside there, you should call $this->renderThenChild() if the condition evaluated to TRUE, and $this->renderElseChild() if the condition evaluated to FALSE.
Every Condition ViewHelper has a "then" and "else" argument, so it can be used like: <[aConditionViewHelperName] .... then="condition true" else="condition false" />, or as well use the "then" and "else" child nodes.
Definition at line 38 of file AbstractConditionViewHelper.php.
__construct | ( | ) |
Initializes the "then" and "else" arguments
Definition at line 61 of file AbstractConditionViewHelper.php.
References AbstractViewHelper\registerArgument().
compile | ( | $argumentsVariableName, | |
$renderChildrenClosureVariableName, | |||
& | $initializationPhpCode, | ||
\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode | $syntaxTreeNode, | ||
\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler | $templateCompiler | ||
) |
The compiled ViewHelper adds two new ViewHelper arguments: __thenClosure and __elseClosure. These contain closures which are be executed to render the then(), respectively else() case.
string | $argumentsVariableName | |
string | $renderChildrenClosureVariableName | |
string | $initializationPhpCode | |
\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode | $syntaxTreeNode | |
\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler | $templateCompiler |
Implements CompilableInterface.
Definition at line 201 of file AbstractConditionViewHelper.php.
References ViewHelperNode\getViewHelperClassName().
|
staticprotected |
This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
array | $arguments | ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method. |
Definition at line 256 of file AbstractConditionViewHelper.php.
References AbstractViewHelper\$arguments.
render | ( | ) |
renders <f:then> child if $condition is true, otherwise renders <f:else> child.
Definition at line 73 of file AbstractConditionViewHelper.php.
References AbstractConditionViewHelper\renderElseChild(), and AbstractConditionViewHelper\renderThenChild().
|
protected |
Returns value of "else" attribute. If else attribute is not set, iterates through child nodes and renders ElseViewHelper. If else attribute is not set and no ElseViewHelper is found, an empty string will be returned.
Definition at line 149 of file AbstractConditionViewHelper.php.
References ViewHelperNode\getViewHelperClassName().
Referenced by AbstractConditionViewHelper\render().
|
static |
Default implementation for CompilableInterface. See CompilableInterface for a detailed description of this method.
array | $arguments | |
\Closure | $renderChildrenClosure | |
\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface | $renderingContext |
Implements CompilableInterface.
Definition at line 230 of file AbstractConditionViewHelper.php.
References AbstractViewHelper\$renderChildrenClosure.
|
staticprotected |
Statically evalute "else" children. The "$hasEvaluated" argument is there to distinguish the case that "else" returned NULL or was not evaluated.
array | $arguments | ViewHelper arguments |
bool | $hasEvaluated | Can be used to check if the "else" child was actually evaluated by this method. |
Definition at line 176 of file AbstractConditionViewHelper.php.
References AbstractViewHelper\$arguments.
|
staticprotected |
Statically evalute "then" children. The "$hasEvaluated" argument is there to distinguish the case that "then" returned NULL or was not evaluated.
array | $arguments | ViewHelper arguments |
bool | $hasEvaluated | Can be used to check if the "then" child was actually evaluated by this method. |
Definition at line 126 of file AbstractConditionViewHelper.php.
References AbstractViewHelper\$arguments, and elseif.
|
protected |
Returns value of "then" attribute. If then attribute is not set, iterates through child nodes and renders ThenViewHelper. If then attribute is not set and no ThenViewHelper and no ElseViewHelper is found, all child nodes are rendered
Definition at line 90 of file AbstractConditionViewHelper.php.
References ViewHelperNode\getViewHelperClassName(), and AbstractViewHelper\renderChildren().
Referenced by AbstractConditionViewHelper\render().
setChildNodes | ( | array | $childNodes | ) |
Setter for ChildNodes - as defined in ChildNodeAccessInterface
array | $childNodes | Child nodes of this syntax tree node |
Implements ChildNodeAccessInterface.
Definition at line 53 of file AbstractConditionViewHelper.php.
References AbstractConditionViewHelper\$childNodes.
|
private |
Definition at line 45 of file AbstractConditionViewHelper.php.
Referenced by AbstractConditionViewHelper\setChildNodes().