‪TYPO3CMS  9.5
ModuleLayoutViewHelper.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
23 use TYPO3Fluid\Fluid\View\Exception;
24 
45 class ‪ModuleLayoutViewHelper extends AbstractViewHelper
46 {
47  use CompileWithRenderStatic;
48 
52  protected ‪$escapeOutput = false;
53 
54  public static function ‪renderStatic(
55  array $arguments,
56  \Closure $renderChildrenClosure,
57  RenderingContextInterface $renderingContext
58  ) {
59  $viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
60  if ($viewHelperVariableContainer->exists(self::class, ModuleTemplate::class)) {
61  throw new Exception('ModuleLayoutViewHelper can only be used once per module.', 1483292643);
62  }
63 
64  $moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
65  $moduleTemplate->setFlashMessageQueue($renderingContext->getControllerContext()->getFlashMessageQueue());
66 
67  $viewHelperVariableContainer->add(self::class, ModuleTemplate::class, $moduleTemplate);
68  $moduleTemplate->setContent($renderChildrenClosure());
69  $viewHelperVariableContainer->remove(self::class, ModuleTemplate::class);
70 
71  return $moduleTemplate->renderContent();
72  }
73 }
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayoutViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: ModuleLayoutViewHelper.php:52
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:40
‪TYPO3\CMS\Backend\ViewHelpers
Definition: AvatarViewHelper.php:2
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayoutViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: ModuleLayoutViewHelper.php:50
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayoutViewHelper
Definition: ModuleLayoutViewHelper.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45