‪TYPO3CMS  ‪main
RenderAllFormValuesViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
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 /*
19  * Inspired by and partially taken from the Neos.Form package (www.neos.io)
20  */
21 
23 
26 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
27 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
28 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
29 
35 final class ‪RenderAllFormValuesViewHelper extends AbstractViewHelper
36 {
37  use CompileWithRenderStatic;
38 
42  protected ‪$escapeOutput = false;
43 
44  public function ‪initializeArguments(): void
45  {
46  $this->registerArgument('renderable', RootRenderableInterface::class, 'A RootRenderableInterface instance', true);
47  $this->registerArgument('as', 'string', 'The name within the template', false, 'formValue');
48  }
49 
53  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
54  {
55  $renderable = $arguments['renderable'];
56 
57  if ($renderable instanceof ‪CompositeRenderableInterface) {
58  $elements = $renderable->getRenderablesRecursively();
59  } else {
60  $elements = [$renderable];
61  }
62 
63  $as = $arguments['as'];
64  ‪$output = '';
65 
66  foreach ($elements as $element) {
68  [
69  'renderable' => $element,
70  'as' => $as,
71  ],
72  $renderChildrenClosure,
73  $renderingContext
74  );
75  }
76 
77  return ‪$output;
78  }
79 }
‪TYPO3\CMS\Form\ViewHelpers\RenderAllFormValuesViewHelper
Definition: RenderAllFormValuesViewHelper.php:36
‪TYPO3\CMS\Form\ViewHelpers\RenderAllFormValuesViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: RenderAllFormValuesViewHelper.php:51
‪TYPO3\CMS\Form\ViewHelpers\RenderFormValueViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: RenderFormValueViewHelper.php:56
‪TYPO3\CMS\Form\ViewHelpers\RenderAllFormValuesViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: RenderAllFormValuesViewHelper.php:40
‪TYPO3\CMS\Form\ViewHelpers\RenderAllFormValuesViewHelper\initializeArguments
‪initializeArguments()
Definition: RenderAllFormValuesViewHelper.php:42
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface
Definition: RootRenderableInterface.php:31
‪$output
‪$output
Definition: annotationChecker.php:119
‪TYPO3\CMS\Form\ViewHelpers
‪TYPO3\CMS\Form\Domain\Model\Renderable\CompositeRenderableInterface
Definition: CompositeRenderableInterface.php:32