TYPO3  7.6
Classes/ViewHelpers/SectionViewHelper.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 
57 {
64  public function initializeArguments()
65  {
66  $this->registerArgument('name', 'string', 'Name of the section', true);
67  }
68 
78  public static function postParseEvent(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer)
79  {
80  $sectionName = $viewHelperArguments['name']->getText();
81  if (!$variableContainer->exists('sections')) {
82  $variableContainer->add('sections', array());
83  }
84  $sections = $variableContainer->get('sections');
85  $sections[$sectionName] = $syntaxTreeNode;
86  $variableContainer->remove('sections');
87  $variableContainer->add('sections', $sections);
88  }
89 
96  public function render()
97  {
98  if ($this->viewHelperVariableContainer->exists(\TYPO3\CMS\Fluid\ViewHelpers\SectionViewHelper::class, 'isCurrentlyRenderingSection')) {
99  $this->viewHelperVariableContainer->remove(\TYPO3\CMS\Fluid\ViewHelpers\SectionViewHelper::class, 'isCurrentlyRenderingSection');
100  return $this->renderChildren();
101  }
102  return '';
103  }
104 
115  public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
116  {
117  return '\'\'';
118  }
119 }