TYPO3 CMS  TYPO3_7-6
SwitchViewHelper.php
Go to the documentation of this file.
1 <?php
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 = [];
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  [
82  'expression' => $expression
83  ],
85  $this->renderingContext
86  );
87  }
88 
100  {
102 
103  $stackValue = [
104  'expression' => $arguments['expression'],
105  'break' => false
106  ];
107 
108  if ($viewHelperVariableContainer->exists(self::class, 'stateStack')) {
109  $stateStack = $viewHelperVariableContainer->get(self::class, 'stateStack');
110  } else {
111  $stateStack = [];
112  }
113  $stateStack[] = $stackValue;
114  $viewHelperVariableContainer->addOrUpdate(self::class, 'stateStack', $stateStack);
115 
116  $result = $renderChildrenClosure();
117 
118  $stateStack = $viewHelperVariableContainer->get(self::class, 'stateStack');
119  array_pop($stateStack);
120  $viewHelperVariableContainer->addOrUpdate(self::class, 'stateStack', $stateStack);
121 
122  return $result;
123  }
124 }
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)