‪TYPO3CMS  ‪main
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 
21 use TYPO3\CMS\Core\Imaging\IconSize;
24 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
25 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
26 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
27 
46 final class ‪IconForResourceViewHelper extends AbstractViewHelper
47 {
48  use CompileWithRenderStatic;
49 
55  protected ‪$escapeOutput = false;
56 
57  public function ‪initializeArguments(): void
58  {
59  $this->registerArgument('resource', ResourceInterface::class, 'Resource', true);
60  $this->registerArgument('size', 'string', 'The icon size', false, IconSize::SMALL);
61  $this->registerArgument('overlay', 'string', 'Overlay identifier', false, null);
62  $this->registerArgument('options', 'array', 'An associative array with additional options', false, []);
63  $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative markup identifier', false);
64  }
65 
66  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
67  {
68  $resource = $arguments['resource'];
69  $size = $arguments['size'];
70  $overlay = $arguments['overlay'];
71  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
72  return $iconFactory->getIconForResource($resource, $size, $overlay, $arguments['options'])->render($arguments['alternativeMarkupIdentifier']);
73  }
74 }
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\initializeArguments
‪initializeArguments()
Definition: IconForResourceViewHelper.php:55
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: IconForResourceViewHelper.php:53
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper
Definition: IconForResourceViewHelper.php:47
‪TYPO3\CMS\Core\ViewHelpers
Definition: IconForRecordViewHelper.php:18
‪TYPO3\CMS\Core\Resource\ResourceInterface
Definition: ResourceInterface.php:21
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\ViewHelpers\IconForResourceViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: IconForResourceViewHelper.php:64