‪TYPO3CMS  10.4
ModuleLayoutViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
25 use TYPO3Fluid\Fluid\View\Exception;
26 
47 class ‪ModuleLayoutViewHelper extends AbstractViewHelper
48 {
49  use CompileWithRenderStatic;
50 
54  protected ‪$escapeOutput = false;
55 
56  public static function ‪renderStatic(
57  array $arguments,
58  \Closure $renderChildrenClosure,
59  RenderingContextInterface $renderingContext
60  ) {
61  $viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
62  if ($viewHelperVariableContainer->exists(self::class, ModuleTemplate::class)) {
63  throw new Exception('ModuleLayoutViewHelper can only be used once per module.', 1483292643);
64  }
65 
66  $moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
67  $moduleTemplate->setFlashMessageQueue($renderingContext->getControllerContext()->getFlashMessageQueue());
68 
69  $viewHelperVariableContainer->add(self::class, ModuleTemplate::class, $moduleTemplate);
70  $moduleTemplate->setContent($renderChildrenClosure());
71  $viewHelperVariableContainer->remove(self::class, ModuleTemplate::class);
72 
73  return $moduleTemplate->renderContent();
74  }
75 }
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayoutViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: ModuleLayoutViewHelper.php:54
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:43
‪TYPO3\CMS\Backend\ViewHelpers
Definition: ArrayBrowserViewHelper.php:18
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayoutViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: ModuleLayoutViewHelper.php:52
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayoutViewHelper
Definition: ModuleLayoutViewHelper.php:48
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46