‪TYPO3CMS  9.5
IconForResourceViewHelper.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 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 
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
25 
44 class ‪IconForResourceViewHelper extends AbstractViewHelper
45 {
46  use CompileWithRenderStatic;
47 
53  protected ‪$escapeOutput = false;
54 
58  public function ‪initializeArguments()
59  {
60  $this->registerArgument('resource', ResourceInterface::class, 'Resource', true);
61  $this->registerArgument('size', 'string', 'The icon size', false, ‪Icon::SIZE_SMALL);
62  $this->registerArgument('overlay', 'string', 'Overlay identifier', false, null);
63  $this->registerArgument('options', 'array', 'An associative array with additional options', false, []);
64  $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative markup identifier', false, null);
65  }
66 
73  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
74  {
75  $resource = $arguments['resource'];
76  $size = $arguments['size'];
77  $overlay = $arguments['overlay'];
78  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
79  return $iconFactory->getIconForResource($resource, $size, $overlay, $arguments['options'])->render($arguments['alternativeMarkupIdentifier']);
80  }
81 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\initializeArguments
‪initializeArguments()
Definition: IconForResourceViewHelper.php:56
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: IconForResourceViewHelper.php:51
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper
Definition: IconForResourceViewHelper.php:45
‪TYPO3\CMS\Core\ViewHelpers
Definition: IconForRecordViewHelper.php:2
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: IconForResourceViewHelper.php:71
‪TYPO3\CMS\Core\Resource\ResourceInterface
Definition: ResourceInterface.php:21
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45