TYPO3  7.6
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | List of all members
AbstractConditionViewHelper Class Reference
Inheritance diagram for AbstractConditionViewHelper:
AbstractViewHelper ChildNodeAccessInterface CompilableInterface IfAuthenticatedViewHelper IfHasRoleViewHelper IfViewHelper IfAuthenticatedViewHelper IfHasRoleViewHelper

Public Member Functions

 setChildNodes (array $childNodes)
 
 __construct ()
 
 render ()
 
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode,\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode,\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 
- Public Member Functions inherited from AbstractViewHelper
 setArguments (array $arguments)
 
 setRenderingContext (\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
 injectReflectionService (\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
 
 isEscapingInterceptorEnabled ()
 
 setViewHelperNode (\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $node)
 
 setRenderChildrenClosure (\Closure $renderChildrenClosure)
 
 initializeArgumentsAndRender ()
 
 initialize ()
 
 renderChildren ()
 
 prepareArguments ()
 
 validateArguments ()
 
 initializeArguments ()
 
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode,\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode,\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 
 resetState ()
 

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
 

Detailed Description

This view helper is an abstract ViewHelper which implements an if/else condition.

See Also
TYPO3::convertArgumentValue() to find see how boolean arguments are evaluated

= 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.

See Also
TYPO3 for a more detailed explanation and a simple usage example. Make sure to NOT OVERRIDE the constructor.

Definition at line 38 of file AbstractConditionViewHelper.php.

Constructor & Destructor Documentation

__construct ( )

Initializes the "then" and "else" arguments

Definition at line 61 of file AbstractConditionViewHelper.php.

References AbstractViewHelper\registerArgument().

Member Function Documentation

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.

Parameters
string$argumentsVariableName
string$renderChildrenClosureVariableName
string$initializationPhpCode
\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode$syntaxTreeNode
\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler$templateCompiler
Returns
string

Implements CompilableInterface.

Definition at line 201 of file AbstractConditionViewHelper.php.

References ViewHelperNode\getViewHelperClassName().

static evaluateCondition (   $arguments = null)
staticprotected

This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.

Parameters
array$argumentsViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
Returns
bool

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.

Returns
string the rendered string

Definition at line 73 of file AbstractConditionViewHelper.php.

References AbstractConditionViewHelper\renderElseChild(), and AbstractConditionViewHelper\renderThenChild().

renderElseChild ( )
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.

Returns
string rendered ElseViewHelper or an empty string if no ThenViewHelper was found

Definition at line 149 of file AbstractConditionViewHelper.php.

References ViewHelperNode\getViewHelperClassName().

Referenced by AbstractConditionViewHelper\render().

static renderStatic ( array  $arguments,
\Closure  $renderChildrenClosure,
\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface  $renderingContext 
)
static

Default implementation for CompilableInterface. See CompilableInterface for a detailed description of this method.

Parameters
array$arguments
\Closure$renderChildrenClosure
\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface$renderingContext
Returns
mixed
See Also

Implements CompilableInterface.

Definition at line 230 of file AbstractConditionViewHelper.php.

References AbstractViewHelper\$renderChildrenClosure.

static renderStaticElseChild (   $arguments,
$hasEvaluated 
)
staticprotected

Statically evalute "else" children. The "$hasEvaluated" argument is there to distinguish the case that "else" returned NULL or was not evaluated.

Parameters
array$argumentsViewHelper arguments
bool$hasEvaluatedCan be used to check if the "else" child was actually evaluated by this method.
Returns
string

Definition at line 176 of file AbstractConditionViewHelper.php.

References AbstractViewHelper\$arguments.

static renderStaticThenChild (   $arguments,
$hasEvaluated 
)
staticprotected

Statically evalute "then" children. The "$hasEvaluated" argument is there to distinguish the case that "then" returned NULL or was not evaluated.

Parameters
array$argumentsViewHelper arguments
bool$hasEvaluatedCan be used to check if the "then" child was actually evaluated by this method.
Returns
string

Definition at line 126 of file AbstractConditionViewHelper.php.

References AbstractViewHelper\$arguments, and elseif.

renderThenChild ( )
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

Returns
string rendered ThenViewHelper or contents of <f:if> if no ThenViewHelper was found

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

Parameters
array$childNodesChild nodes of this syntax tree node
Returns
void

Implements ChildNodeAccessInterface.

Definition at line 53 of file AbstractConditionViewHelper.php.

References AbstractConditionViewHelper\$childNodes.

Member Data Documentation

$childNodes = array()
private