‪TYPO3CMS  9.5
FluidFormRenderer.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 originated from the Neos.Form package (www.neos.io)
9  *
10  * It is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License, either version 2
12  * of the License, or any later version.
13  *
14  * For the full copyright and license information, please read the
15  * LICENSE.txt file that was distributed with this source code.
16  *
17  * The TYPO3 project - inspiring people to share!
18  */
19 
25 
124 {
125 
139  public function ‪render(): string
140  {
141  $formElementType = $this->formRuntime->getType();
142  $renderingOptions = $this->formRuntime->getRenderingOptions();
143 
144  $view = GeneralUtility::makeInstance(ObjectManager::class)
145  ->get(TemplateView::class);
146  $view->setControllerContext($this->controllerContext);
147 
148  if (!isset($renderingOptions['templateRootPaths'])) {
149  throw new ‪RenderingException(
150  sprintf('The option templateRootPaths must be set for renderable "%s"', $formElementType),
151  1480293084
152  );
153  }
154  if (!isset($renderingOptions['layoutRootPaths'])) {
155  throw new ‪RenderingException(
156  sprintf('The option layoutRootPaths must be set for renderable "%s"', $formElementType),
157  1480293085
158  );
159  }
160  if (!isset($renderingOptions['partialRootPaths'])) {
161  throw new ‪RenderingException(
162  sprintf('The option partialRootPaths must be set for renderable "%s"', $formElementType),
163  1480293086
164  );
165  }
166 
167  $view->assign('form', $this->formRuntime);
168 
169  $view->getRenderingContext()
170  ->getViewHelperVariableContainer()
171  ->addOrUpdate(RenderRenderableViewHelper::class, 'formRuntime', $this->formRuntime);
172 
173  // Configure the fluid TemplatePaths with the rendering options
174  // from the renderable
175  $view->getTemplatePaths()->fillFromConfigurationArray($renderingOptions);
176 
177  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'] ?? [] as $className) {
178  $hookObj = GeneralUtility::makeInstance($className);
179  if (method_exists($hookObj, 'beforeRendering')) {
180  $hookObj->beforeRendering(
181  $this->formRuntime,
182  $this->formRuntime->getFormDefinition()
183  );
184  }
185  }
186 
187  return $view->render($this->formRuntime->getTemplateName());
188  }
189 }
‪TYPO3\CMS\Form\Domain\Renderer
Definition: AbstractElementRenderer.php:3
‪TYPO3\CMS\Fluid\View\TemplateView
Definition: TemplateView.php:24
‪TYPO3\CMS\Form\Domain\Renderer\FluidFormRenderer
Definition: FluidFormRenderer.php:124
‪TYPO3\CMS\Form\Domain\Renderer\AbstractElementRenderer
Definition: AbstractElementRenderer.php:29
‪TYPO3\CMS\Form\ViewHelpers\RenderRenderableViewHelper
Definition: RenderRenderableViewHelper.php:37
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Form\Domain\Exception\RenderingException
Definition: RenderingException.php:26
‪TYPO3\CMS\Form\Domain\Renderer\FluidFormRenderer\render
‪string render()
Definition: FluidFormRenderer.php:139
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25