AbstractConditionViewHelper
abstract class AbstractConditionViewHelper extends AbstractViewHelper (View source)
This view helper is an abstract ViewHelper which implements an if/else condition.
Properties
protected ControllerContext | $controllerContext | Controller Context to use |
from AbstractViewHelper |
protected ObjectManagerInterface | $objectManager | from AbstractViewHelper | |
protected LoggerInterface | $logger | from AbstractViewHelper | |
protected bool | $escapeOutput |
Methods
No description
Injects the (system) logger based on PSR-3.
Register a new argument. Call this method from your ViewHelper subclass inside the initializeArguments() method.
Overrides a registered argument. Call this method from your ViewHelper subclass inside the initializeArguments() method if you want to override a previously registered argument.
Initializes the "then" and "else" arguments
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.
No description
No description
Returns value of "then" attribute.
Returns value of "else" attribute.
The compiled ViewHelper adds two new ViewHelper arguments: thenClosure and elseClosure.
No description
Details
void
setRenderingContext(RenderingContextInterface $renderingContext)
No description
void
injectObjectManager(ObjectManagerInterface $objectManager)
No description
void
injectLogger(LoggerInterface $logger)
Injects the (system) logger based on PSR-3.
protected AbstractViewHelper
registerArgument(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null, bool|null $escape = null)
Register a new argument. Call this method from your ViewHelper subclass inside the initializeArguments() method.
This exists only to throw our own exception!
protected AbstractViewHelper
overrideArgument(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null, bool|null $escape = null)
Overrides a registered argument. Call this method from your ViewHelper subclass inside the initializeArguments() method if you want to override a previously registered argument.
This exists only to throw our own exception!
bool
isEscapingInterceptorEnabled()
No description
initializeArguments()
Initializes the "then" and "else" arguments
static protected bool
evaluateCondition(array|null $arguments = null, RenderingContextInterface $renderingContext)
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.
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!
static mixed
renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
No description
static protected string
evaluateElseClosures(array $closures, array $conditionClosures, RenderingContextInterface $renderingContext)
No description
protected mixed
renderThenChild()
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
protected string
renderElseChild()
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.
string
compile(string $argumentsName, string $closureName, string $initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
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.
static protected string
renderResult(bool $isConditionFullfilled, array $arguments, RenderingContextInterface $renderingContext)
No description