PHP Class Neos\FluidAdaptor\Core\ViewHelper\AbstractConditionViewHelper

See also: Neos\FluidAdaptor\Core\Parser\SyntaxTree\ViewHelperNode::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: Neos\FluidAdaptor\ViewHelpers\IfViewHelper for a more detailed explanation and a simple usage example. Make sure to NOT OVERRIDE the constructor.
Inheritance: extends AbstractViewHelper
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$escapeOutput boolean

Méthodes publiques

Méthode Description
compile ( string $argumentsName, string $closureName, string &$initializationPhpCode, TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $node, TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler $compiler ) : string The compiled ViewHelper adds two new ViewHelper arguments: __thenClosure and __elseClosure.
initializeArguments ( ) Initializes the "then" and "else" arguments
renderStatic ( array $arguments, Closure $renderChildrenClosure, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : mixed

Méthodes protégées

Méthode Description
evaluateCondition ( array | null $arguments = null, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : boolean Static method which can be overridden by subclasses. If a subclass requires a different (or faster) decision then this method is the one to override and implement.
evaluateElseClosures ( array $closures, array $conditionClosures, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : string
renderElseChild ( ) : string Returns value of "else" attribute.
renderResult ( boolean $isConditionFullfilled, array $arguments, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : string
renderThenChild ( ) : mixed Returns value of "then" attribute.

Method Details

compile() public méthode

These contain closures which are be executed to render the then(), respectively else() case.
public compile ( string $argumentsName, string $closureName, string &$initializationPhpCode, TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $node, TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler $compiler ) : string
$argumentsName string
$closureName string
$initializationPhpCode string
$node TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode
$compiler TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler
Résultat string

evaluateCondition() protected static méthode

Note: method signature does not type-hint that an array is desired, and as such, *appears* to accept any input type. There is no type hint here for legacy reasons - the signature is kept compatible with third party packages which depending on PHP version would error out if this signature was not compatible with that of existing and in-production subclasses that will be using this base class in the future. Let this be a warning if someone considers changing this method signature!
protected static evaluateCondition ( array | null $arguments = null, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : boolean
$arguments array | null
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
Résultat boolean

evaluateElseClosures() protected static méthode

protected static evaluateElseClosures ( array $closures, array $conditionClosures, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : string
$closures array
$conditionClosures array
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
Résultat string

initializeArguments() public méthode

Initializes the "then" and "else" arguments
public initializeArguments ( )

renderElseChild() protected méthode

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.
protected renderElseChild ( ) : string
Résultat string rendered ElseViewHelper or an empty string if no ThenViewHelper was found

renderResult() protected static méthode

protected static renderResult ( boolean $isConditionFullfilled, array $arguments, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : string
$isConditionFullfilled boolean
$arguments array
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
Résultat string

renderStatic() public static méthode

public static renderStatic ( array $arguments, Closure $renderChildrenClosure, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : mixed
$arguments array
$renderChildrenClosure Closure
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
Résultat mixed

renderThenChild() protected méthode

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
protected renderThenChild ( ) : mixed
Résultat mixed rendered ThenViewHelper or contents of if no ThenViewHelper was found

Property Details

$escapeOutput protected_oe property

protected bool $escapeOutput
Résultat boolean