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

Public Member Functions

 setChildNodes (array $childNodes)
 
 render ($expression)
 
- 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 ()
 
- Public Member Functions inherited from CompilableInterface
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode,\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode,\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 

Static Public Member Functions

static renderStatic (array $arguments,\Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 
- Static Public Member Functions inherited from AbstractViewHelper
static renderStatic (array $arguments,\Closure $renderChildrenClosure,\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Static Public Member Functions inherited from CompilableInterface
static renderStatic (array $arguments,\Closure $renderChildrenClosure,\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 

Protected Attributes

 $backupSwitchExpression = null
 
 $backupBreakState = false
 
- Protected Attributes inherited from AbstractViewHelper
 $arguments
 
 $templateVariableContainer
 
 $controllerContext
 
 $renderingContext
 
 $renderChildrenClosure = null
 
 $viewHelperVariableContainer
 
 $objectManager
 
 $escapingInterceptorEnabled = true
 

Private Attributes

 $childNodes = array()
 

Additional Inherited Members

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

Detailed Description

Switch view helper which can be used to render content depending on a value or expression. Implements what a basic switch()-PHP-method does.

= Examples =

<f:switch expression="{person.gender}"> <f:case value="male">Mr.</f:case> <f:case value="female">Mrs.</f:case> <f:case default="TRUE">Mrs. or Mr.</f:case> </f:switch> <output> Mr. / Mrs. (depending on the value of {person.gender}) or if no value evaluates to TRUE, default case </output>

Note: Using this view helper can be a sign of weak architecture. If you end up using it extensively you might want to consider restructuring your controllers/actions and/or use partials and sections. E.g. the above example could be achieved with <f:render partial="title.{person.gender}" /> and the partials "title.male.html", "title.female.html", ... Depending on the scenario this can be easier to extend and possibly contains less duplication.

Definition at line 44 of file SwitchViewHelper.php.

Member Function Documentation

render (   $expression)
Parameters
mixed$expression
Returns
string the rendered string

Definition at line 78 of file SwitchViewHelper.php.

References AbstractViewHelper\buildRenderChildrenClosure().

static renderStatic ( array  $arguments,
\Closure  $renderChildrenClosure,
RenderingContextInterface  $renderingContext 
)
static

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

Parameters
array$arguments
\Closure$renderChildrenClosure
RenderingContextInterface$renderingContext
Returns
mixed
See Also

Definition at line 99 of file SwitchViewHelper.php.

References AbstractViewHelper\$renderChildrenClosure, AbstractViewHelper\$viewHelperVariableContainer, and RenderingContextInterface\getViewHelperVariableContainer().

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 68 of file SwitchViewHelper.php.

References SwitchViewHelper\$childNodes.

Member Data Documentation

$backupBreakState = false
protected

Definition at line 60 of file SwitchViewHelper.php.

$backupSwitchExpression = null
protected

Definition at line 55 of file SwitchViewHelper.php.

$childNodes = array()
private

Definition at line 50 of file SwitchViewHelper.php.

Referenced by SwitchViewHelper\setChildNodes().