IfAuthenticatedViewHelper
class IfAuthenticatedViewHelper extends AbstractConditionViewHelper (View source)
This view helper implements an ifAuthenticated/else condition.
= Examples =
This is being shown whenever a user is logged in
```
Everything inside the tag is being displayed if you are authenticated with any account.
This is being shown in case you have access.
This is being displayed in case you do not have access.
```
Everything inside the "then" tag is displayed if you have access.
Otherwise, everything inside the "else"-tag is displayed.
Properties
protected ControllerContext
$controllerContext
Controller Context to use
from
AbstractViewHelper
protected ObjectManagerInterface
$objectManager
from
AbstractViewHelper
protected LoggerInterface
$logger
from
AbstractViewHelper
protected bool
$escapeOutput
from
AbstractConditionViewHelper
Methods
void
setRenderingContext(RenderingContextInterface $renderingContext)
No description
from
AbstractViewHelper
void
from
AbstractViewHelper
void
injectLogger(LoggerInterface $logger)
Injects the (system) logger based on PSR-3.
from
AbstractViewHelper
static bool
evaluateCondition(array|null $arguments, RenderingContextInterface $renderingContext)
No description
static mixed
renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
No description
static string
evaluateElseClosures(array $closures, array $conditionClosures, RenderingContextInterface $renderingContext)
No description
string
compile(string $argumentsName, string $closureName, string $initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
The compiled ViewHelper adds two new ViewHelper arguments: thenClosure and elseClosure.
static string
renderResult(bool $isConditionFullfilled, array $arguments, RenderingContextInterface $renderingContext)
No description
string
render()
renders child if access to the given resource is allowed, otherwise renders child.
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.
bool
isEscapingInterceptorEnabled()
No description
initializeArguments()
Initializes the "then" and "else" arguments
static protected bool
evaluateCondition(array|null $arguments, RenderingContextInterface $renderingContext)
No description
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
string
render()
renders child if access to the given resource is allowed, otherwise renders child.