0f2311d6696664e6220dc22254fa62cbb312a5de
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Renderer / FluidFormRenderer.php
1 <?php
2 declare(strict_types=1);
3 namespace TYPO3\CMS\Form\Domain\Renderer;
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\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Extbase\Object\ObjectManager;
20 use TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface;
21 use TYPO3\CMS\Form\Mvc\View\FormView;
22
23 /**
24 * A renderer which render all renderables within the $formRuntime.
25 * All the work is done within FormView::class.
26 * This is just a proxy class to make the rendering process more clear.
27 * See the documentation within FormView::class for additional information.
28 *
29 * Scope: frontend
30 * **This class is NOT meant to be sub classed by developers.**
31 * @internal
32 */
33 class FluidFormRenderer extends AbstractElementRenderer implements RendererInterface
34 {
35
36 /**
37 * Initialize the FormView::class and render the this->formRuntime.
38 * This method is expected to invoke the beforeRendering() callback
39 * on each $renderable. This is done within FormView::class.
40 *
41 * @param RootRenderableInterface $renderable
42 * @return string the rendered $formRuntime
43 * @internal
44 */
45 public function render(RootRenderableInterface $renderable): string
46 {
47 $formView = GeneralUtility::makeInstance(ObjectManager::class)
48 ->get(FormView::class);
49
50 $formView->setFormRuntime($this->formRuntime);
51 $formView->setControllerContext($this->controllerContext);
52 return $formView->renderRenderable($renderable);
53 }
54 }