Inline font styles, remove obsolete icon font
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Service\ImageService;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class IconViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('icon', 'string', 'Icon name');
|
||||
$this->registerArgument('class', 'string', 'CSS classes');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$imageService = self::getImageService();
|
||||
$sprite = $imageService->getImage('EXT:ep_theme/Resources/Public/images/icons_sprite.svg', null, false);
|
||||
$imageUrl = $sprite->getPublicUrl();
|
||||
|
||||
return sprintf(
|
||||
'<svg class="%s"><use href="%s#icon-%s"></use></svg>',
|
||||
$arguments['class'],
|
||||
$imageUrl,
|
||||
$arguments['icon']
|
||||
);
|
||||
}
|
||||
|
||||
protected static function getImageService()
|
||||
{
|
||||
return GeneralUtility::makeInstance(ImageService::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user