PHP Класс Neos\FluidAdaptor\Core\ViewHelper\AbstractConditionViewHelper

См. также: 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.
См. также: Neos\FluidAdaptor\ViewHelpers\IfViewHelper for a more detailed explanation and a simple usage example. Make sure to NOT OVERRIDE the constructor.
Наследование: extends AbstractViewHelper
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$escapeOutput boolean

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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.

Описание методов

compile() публичный Метод

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
Результат string

evaluateCondition() защищенный статический Метод

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
Результат boolean

evaluateElseClosures() защищенный статический Метод

protected static evaluateElseClosures ( array $closures, array $conditionClosures, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : string
$closures array
$conditionClosures array
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
Результат string

initializeArguments() публичный Метод

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

renderElseChild() защищенный Метод

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
Результат string rendered ElseViewHelper or an empty string if no ThenViewHelper was found

renderResult() защищенный статический Метод

protected static renderResult ( boolean $isConditionFullfilled, array $arguments, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : string
$isConditionFullfilled boolean
$arguments array
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
Результат string

renderStatic() публичный статический Метод

public static renderStatic ( array $arguments, Closure $renderChildrenClosure, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : mixed
$arguments array
$renderChildrenClosure Closure
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
Результат mixed

renderThenChild() защищенный Метод

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
Результат mixed rendered ThenViewHelper or contents of if no ThenViewHelper was found

Описание свойств

$escapeOutput защищенное свойство

protected bool $escapeOutput
Результат boolean