* ``` * * @see https://docs.typo3.org/permalink/t3viewhelper:typo3-core-iconforresource * @see \TYPO3\CMS\Core\Resource\ResourceInterface */ final class IconForResourceViewHelper extends AbstractViewHelper { /** * ViewHelper returns HTML, thus we need to disable output escaping * * @var bool */ protected $escapeOutput = false; public function __construct( private readonly IconFactory $iconFactory ) {} public function initializeArguments(): void { $this->registerArgument('resource', ResourceInterface::class, 'Resource', true); $this->registerArgument('size', 'string', 'The icon size', false, IconSize::SMALL); $this->registerArgument('overlay', 'string', 'Overlay identifier', false, null); $this->registerArgument('options', 'array', 'An associative array with additional options', false, []); $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative markup identifier'); } public function render(): string { $resource = $this->arguments['resource']; if (!($resource instanceof ResourceInterface)) { return ''; } $size = $this->arguments['size']; $overlay = $this->arguments['overlay']; return $this->iconFactory->getIconForResource($resource, $size, $overlay, $this->arguments['options'])->render($this->arguments['alternativeMarkupIdentifier']); } }