‪TYPO3CMS  10.4
TranslateElementErrorViewHelper.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 
19 
24 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
25 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
26 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
27 
33 class ‪TranslateElementErrorViewHelper extends AbstractViewHelper
34 {
35  use CompileWithRenderStatic;
36 
42  public function ‪initializeArguments()
43  {
44  $this->registerArgument('element', RootRenderableInterface::class, 'Form Element to translate', true);
45  $this->registerArgument('error', Error::class, 'Error', true);
46  }
47 
56  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
57  {
58  $element = $arguments['element'];
59  $error = $arguments['error'];
60 
62  $formRuntime = $renderingContext
63  ->getViewHelperVariableContainer()
64  ->get(RenderRenderableViewHelper::class, 'formRuntime');
65 
67  $element,
68  $error->getCode(),
69  $error->getArguments(),
70  $error->__toString(),
71  $formRuntime
72  );
73  }
74 }
‪TYPO3\CMS\Form\Service\TranslationService\getInstance
‪static TranslationService getInstance()
Definition: TranslationService.php:83
‪TYPO3\CMS\Form\Service\TranslationService
Definition: TranslationService.php:44
‪TYPO3\CMS\Form\ViewHelpers\TranslateElementErrorViewHelper
Definition: TranslateElementErrorViewHelper.php:34
‪TYPO3\CMS\Form\Service\TranslationService\translateFormElementError
‪string translateFormElementError(RootRenderableInterface $element, int $code, array $arguments, string $defaultValue='', FormRuntime $formRuntime)
Definition: TranslationService.php:454
‪TYPO3\CMS\Extbase\Error\Error
Definition: Error.php:25
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface
Definition: RootRenderableInterface.php:31
‪TYPO3\CMS\Form\ViewHelpers\TranslateElementErrorViewHelper\initializeArguments
‪initializeArguments()
Definition: TranslateElementErrorViewHelper.php:41
‪TYPO3\CMS\Form\ViewHelpers
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormSession.php:18
‪TYPO3\CMS\Form\ViewHelpers\TranslateElementErrorViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: TranslateElementErrorViewHelper.php:55