Files
typo3-13/packages/ep_theme/Classes/ViewHelpers/IconViewHelper.php
T
frommeandClaude Opus 5.5 4fe06267c9 refactor: code quality via Rector, strict types where safe
rector.php gets the codeQuality set: declare(strict_types=1) in the 85
files where Rector finds no call relying on scalar type juggling (mostly
TCA and configuration, models, the content feed API and the import
command), "or die" as "|| die", instanceof instead of null checks for
object types, early returns and self:: in final classes.

Hotel::setRooms() goes instead of getting the property Rector wanted to
declare: nothing calls it, and there is no rooms column any more.

Checked locally: cache warmup, the ep:* commands load, frontend crawl
(~1,900 URLs) and the backchannel APIs render the same as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 11:15:38 +01:00

41 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
*/
#[\Override]
protected $tagName = 'svg';
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('icon', 'string', 'Icon name', true);
}
public function render(): string
{
$imageService = $this->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();
}
private function getImageService()
{
return GeneralUtility::makeInstance(ImageService::class);
}
}