[FEATURE] EXT:form - integrate new form framework
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / ViewHelpers / RenderRenderableViewHelper.php
1 <?php
2 declare(strict_types=1);
3 namespace TYPO3\CMS\Form\ViewHelpers;
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
18 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface;
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
22
23 /**
24 * Render a renderable.
25 *
26 * Set the renderable into the \TYPO3\CMS\Form\Mvc\View\FormView
27 * and return the rendered content.
28 *
29 * Scope: frontend
30 * @api
31 */
32 class RenderRenderableViewHelper extends AbstractViewHelper
33 {
34 use CompileWithRenderStatic;
35
36 /**
37 * @var bool
38 */
39 protected $escapeOutput = false;
40
41 /**
42 * Initialize the arguments.
43 *
44 * @return void
45 * @internal
46 */
47 public function initializeArguments()
48 {
49 parent::initializeArguments();
50 $this->registerArgument('renderable', RenderableInterface::class, 'A RenderableInterface instance', true);
51 }
52
53 /**
54 * @param array $arguments
55 * @param callable|\Closure $renderChildrenClosure
56 * @param RenderingContextInterface $renderingContext
57 * @return string
58 * @public
59 */
60 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
61 {
62 /** @var \TYPO3\CMS\Form\Mvc\View\FormView $view */
63 $view = $renderingContext->getViewHelperVariableContainer()->getView();
64 return $view->renderRenderable($arguments['renderable']);
65 }
66 }