[TASK] Convert remaining ViewHelpers to static calling
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / ViewHelpers / IconForRecordViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Core\ViewHelpers;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Imaging\Icon;
18 use TYPO3\CMS\Core\Imaging\IconFactory;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
23
24 /**
25 * Displays icon for record
26 */
27 class IconForRecordViewHelper extends AbstractViewHelper
28 {
29 use CompileWithRenderStatic;
30
31 /**
32 * View helper returns HTML, thus we need to disable output escaping
33 *
34 * @var bool
35 */
36 protected $escapeOutput = false;
37
38 /**
39 * Initializes the arguments
40 */
41 public function initializeArguments()
42 {
43 $this->registerArgument('table', 'string', 'the table for the record icon', true);
44 $this->registerArgument('row', 'array', 'the record row', true);
45 $this->registerArgument('size', 'string', 'the icon size', false, Icon::SIZE_SMALL);
46 $this->registerArgument('alternativeMarkupIdentifier', 'string', 'alternative markup identifier', false, null);
47 }
48
49 /**
50 * @param array $arguments
51 * @param \Closure $renderChildrenClosure
52 * @param RenderingContextInterface $renderingContext
53 * @return string
54 */
55 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
56 {
57 $table = $arguments['table'];
58 $size = $arguments['size'];
59 $row = $arguments['row'];
60 $alternativeMarkupIdentifier = $arguments['alternativeMarkupIdentifier'];
61 /** @var IconFactory $iconFactory */
62 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
63 return $iconFactory->getIconForRecord($table, $row, $size)->render($alternativeMarkupIdentifier);
64 }
65 }