Automated migrations from rector.php and fractor.php (TCA, Extbase controllers and annotations, ViewHelpers, QueryBuilder, FlexForms, TypoScript conditions). Plugins stay list_type plugins: Rector switched them to content element types, which needs a tt_content migration. That is deferred to the TYPO3 14 step, where list_type is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
40 lines
1.1 KiB
PHP
40 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->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);
|
|
}
|
|
}
|