TYPO3  7.6
SwitchViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers;
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 
45 {
50  private $childNodes = array();
51 
55  protected $backupSwitchExpression = null;
56 
60  protected $backupBreakState = false;
61 
68  public function setChildNodes(array $childNodes)
69  {
70  $this->childNodes = $childNodes;
71  }
72 
78  public function render($expression)
79  {
80  return static::renderStatic(
81  array(
82  'expression' => $expression
83  ),
85  $this->renderingContext
86  );
87  }
88 
100  {
102 
103  $stackValue = array(
104  'expression' => $arguments['expression'],
105  'break' => false
106  );
107 
108  if ($viewHelperVariableContainer->exists(SwitchViewHelper::class, 'stateStack')) {
109  $stateStack = $viewHelperVariableContainer->get(SwitchViewHelper::class, 'stateStack');
110  } else {
111  $stateStack = array();
112  }
113  $stateStack[] = $stackValue;
114  $viewHelperVariableContainer->addOrUpdate(SwitchViewHelper::class, 'stateStack', $stateStack);
115 
116  $result = $renderChildrenClosure();
117 
118  $stateStack = $viewHelperVariableContainer->get(SwitchViewHelper::class, 'stateStack');
119  array_pop($stateStack);
120  $viewHelperVariableContainer->addOrUpdate(SwitchViewHelper::class, 'stateStack', $stateStack);
121 
122  return $result;
123  }
124 }