‪TYPO3CMS  10.4
IconForResourceViewHelper.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 
46 class ‪IconForResourceViewHelper extends AbstractViewHelper
47 {
48  use CompileWithRenderStatic;
49 
55  protected ‪$escapeOutput = false;
56 
60  public function ‪initializeArguments()
61  {
62  $this->registerArgument('resource', ResourceInterface::class, 'Resource', true);
63  $this->registerArgument('size', 'string', 'The icon size', false, ‪Icon::SIZE_SMALL);
64  $this->registerArgument('overlay', 'string', 'Overlay identifier', false, null);
65  $this->registerArgument('options', 'array', 'An associative array with additional options', false, []);
66  $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative markup identifier', false, null);
67  }
68 
75  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
76  {
77  $resource = $arguments['resource'];
78  $size = $arguments['size'];
79  $overlay = $arguments['overlay'];
80  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
81  return $iconFactory->getIconForResource($resource, $size, $overlay, $arguments['options'])->render($arguments['alternativeMarkupIdentifier']);
82  }
83 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\initializeArguments
‪initializeArguments()
Definition: IconForResourceViewHelper.php:58
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: IconForResourceViewHelper.php:53
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper
Definition: IconForResourceViewHelper.php:47
‪TYPO3\CMS\Core\ViewHelpers
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: IconForResourceViewHelper.php:73
‪TYPO3\CMS\Core\Resource\ResourceInterface
Definition: ResourceInterface.php:22
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46