* * Output:: * * * * * * * * Inline:: * * * * Output:: * * * * * * * */ class SvgViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; /** * ViewHelper returns HTML, thus we need to disable output escaping * * @var bool */ protected $escapeOutput = false; public function initializeArguments(): void { $this->registerArgument( 'identifier', 'string', 'Identifier of the icon as registered in the Icon Registry.', true ); $this->registerArgument( 'size', 'string', 'Desired size of the icon. All values of the Icons.sizes enum are allowed,' . ' these are: "small", "default", "large" and "overlay".', false, IconSize::SMALL ); $this->registerArgument( 'overlay', 'string', 'Identifier of an overlay icon as registered in the Icon Registry.', false, '' ); $this->registerArgument( 'state', 'string', 'Sets the state of the icon. All values of the Icons.states enum are allowed,' . ' these are: "default" and "disabled".', false, IconState::STATE_DEFAULT ); $this->registerArgument( 'alternativeMarkupIdentifier', 'string', 'Alternative icon identifier. Takes precedence over the identifier if supported by the IconProvider.', false, '' ); } public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext ): Icon { $identifier = $arguments['identifier']; $size = $arguments['size']; $overlay = $arguments['overlay']; $state = IconState::tryFrom($arguments['state']); $alternativeMarkupIdentifier = $arguments['alternativeMarkupIdentifier']; $iconFactory = GeneralUtility::makeInstance(IconFactory::class); return $iconFactory->getIcon($identifier, $size, $overlay, $state)->getMarkup($alternativeMarkupIdentifier); } }