TYPO3 CMS  TYPO3_8-7
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 use TYPO3Fluid\Fluid\ViewHelpers\CaseViewHelper as OriginalCaseViewHelper;
20 
46 class SwitchViewHelper extends \TYPO3Fluid\Fluid\ViewHelpers\SwitchViewHelper
47 {
52  protected function isDefaultCaseNode(NodeInterface $node)
53  {
54  if ($node instanceof ViewHelperNode) {
55  $viewHelperClassName = $node->getViewHelperClassName();
56  $arguments = $node->getArguments();
57  return
58  $viewHelperClassName === DefaultCaseViewHelper::class ||
59  (
60  $viewHelperClassName === CaseViewHelper::class && isset($arguments['default']) && $arguments['default']
61  )
62  ;
63  }
64  return false;
65  }
66 
71  protected function isCaseNode(NodeInterface $node)
72  {
73  if ($node instanceof ViewHelperNode) {
74  $viewHelperClassName = $node->getViewHelperClassName();
75  return $viewHelperClassName === CaseViewHelper::class || $viewHelperClassName === OriginalCaseViewHelper::class;
76  }
77  return false;
78  }
79 
87  public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
88  {
89  if (count($node->getChildNodes())) {
90  throw new StopCompilingException('switch view helper', 1476122366);
91  }
92  }
93 }
compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)