TYPO3 CMS  TYPO3_8-7
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 
26 
125 {
126 
140  public function render(): string
141  {
142  $formElementType = $this->formRuntime->getType();
143  $renderingOptions = $this->formRuntime->getRenderingOptions();
144 
145  $view = GeneralUtility::makeInstance(ObjectManager::class)
146  ->get(TemplateView::class);
147  $view->setControllerContext($this->controllerContext);
148 
149  if (!isset($renderingOptions['templateRootPaths'])) {
150  throw new RenderingException(
151  sprintf('The option templateRootPaths must be set for renderable "%s"', $formElementType),
152  1480293084
153  );
154  }
155  if (!isset($renderingOptions['layoutRootPaths'])) {
156  throw new RenderingException(
157  sprintf('The option layoutRootPaths must be set for renderable "%s"', $formElementType),
158  1480293085
159  );
160  }
161  if (!isset($renderingOptions['partialRootPaths'])) {
162  throw new RenderingException(
163  sprintf('The option partialRootPaths must be set for renderable "%s"', $formElementType),
164  1480293086
165  );
166  }
167 
168  $view->assign('form', $this->formRuntime);
169 
170  $view->getRenderingContext()
171  ->getViewHelperVariableContainer()
172  ->addOrUpdate(RenderRenderableViewHelper::class, 'formRuntime', $this->formRuntime);
173 
174  // Configure the fluid TemplatePaths with the rendering options
175  // from the renderable
176  $view->getTemplatePaths()->fillFromConfigurationArray($renderingOptions);
177 
178  GeneralUtility::deprecationLog('EXT:form - calls for "beforeRendering" are deprecated since TYPO3 v8 and will be removed in TYPO3 v9');
179  $this->formRuntime->getFormDefinition()->beforeRendering($this->formRuntime);
180 
181  if (
182  isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'])
183  && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'])
184  ) {
185  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'] as $className) {
186  $hookObj = GeneralUtility::makeInstance($className);
187  if (method_exists($hookObj, 'beforeRendering')) {
188  $hookObj->beforeRendering(
189  $this->formRuntime,
190  $this->formRuntime->getFormDefinition()
191  );
192  }
193  }
194  }
195 
196  return $view->render($this->formRuntime->getTemplateName());
197  }
198 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']