TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
form/Classes/ViewHelpers/RenderViewHelper.php
Go to the documentation of this file.
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 
23 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
25 
43 {
44  use CompileWithRenderStatic;
45 
49  protected $escapeOutput = false;
50 
57  public function initializeArguments()
58  {
59  parent::initializeArguments();
60  $this->registerArgument('persistenceIdentifier', 'string', 'The persistence identifier for the form.', false, null);
61  $this->registerArgument('factoryClass', 'string', 'The fully qualified class name of the factory', false, ArrayFormFactory::class);
62  $this->registerArgument('prototypeName', 'string', 'Name of the prototype to use', false, null);
63  $this->registerArgument('overrideConfiguration', 'array', 'factory specific configuration', false, []);
64  }
65 
73  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
74  {
75  $persistenceIdentifier = $arguments['persistenceIdentifier'];
76  $factoryClass = $arguments['factoryClass'];
77  $prototypeName = $arguments['prototypeName'];
78  $overrideConfiguration = $arguments['overrideConfiguration'];
79 
80  if (!empty($persistenceIdentifier)) {
81  $formPersistenceManager = $renderingContext->getObjectManager()->get(FormPersistenceManagerInterface::class);
82  $formConfiguration = $formPersistenceManager->load($persistenceIdentifier);
84  $formConfiguration,
85  $overrideConfiguration
86  );
87  $overrideConfiguration = $formConfiguration;
88  $overrideConfiguration['persistenceIdentifier'] = $persistenceIdentifier;
89  }
90 
91  if (empty($prototypeName)) {
92  $prototypeName = isset($overrideConfiguration['prototypeName']) ? $overrideConfiguration['prototypeName'] : 'standard';
93  }
94 
95  $factory = $renderingContext->getObjectManager()->get($factoryClass);
96  $formDefinition = $factory->build($overrideConfiguration, $prototypeName);
97  $response = $renderingContext->getObjectManager()->get(Response::class, $renderingContext->getControllerContext()->getResponse());
98  $form = $formDefinition->bind($renderingContext->getControllerContext()->getRequest(), $response);
99  return $form->render();
100  }
101 }
static renderStatic(array $arguments,\Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)