Copied unchanged from public/typo3conf/ext/ of EP/website at 9593cc8631354f8a363d6609de8b7433f669a9a0 (Git-tracked files only). History stays in the old repository. Only composer.json files are added so the extensions install as path packages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace EP\EpTheme\ViewHelpers;
|
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3\CMS\Extbase\Service\ImageService;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
|
|
|
|
class IconViewHelper extends AbstractTagBasedViewHelper
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $tagName = 'svg';
|
|
|
|
public function initializeArguments()
|
|
{
|
|
parent::initializeArguments();
|
|
|
|
$this->registerUniversalTagAttributes();
|
|
$this->registerArgument('icon', 'string', 'Icon name', true);
|
|
}
|
|
|
|
public function render(): string
|
|
{
|
|
$imageService = self::getImageService();
|
|
$sprite = $imageService->getImage('EXT:ep_theme/Resources/Public/images/icons_sprite.svg', null, false);
|
|
$imageUrl = $sprite->getPublicUrl();
|
|
|
|
$content = sprintf('<use href="%s#icon-%s"></use>', $imageUrl, $this->arguments['icon']);
|
|
$this->tag->setContent($content);
|
|
$this->tag->addAttributes(['aria-hidden' => 'true']);
|
|
|
|
return $this->tag->render();
|
|
}
|
|
|
|
protected static function getImageService()
|
|
{
|
|
return GeneralUtility::makeInstance(ImageService::class);
|
|
}
|
|
}
|