*
* Output::
*
*
*
* Inline::
*
*
*
* Output::
*
*
*/
class SvgViewHelper extends AbstractViewHelper
{
/**
* 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.');
$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.');
}
/**
* Prints icon html for $identifier key
*
* @return string
*/
public function render(): string
{
$identifier = $this->arguments['identifier'];
$size = $this->arguments['size'];
$overlay = $this->arguments['overlay'];
$state = IconState::tryFrom($this->arguments['state']);
$alternativeMarkupIdentifier = $this->arguments['alternativeMarkupIdentifier'];
/** @var IconFactory $iconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
return $iconFactory->getIcon($identifier, $size, $overlay, $state)->getMarkup($alternativeMarkupIdentifier);
}
}