FontAwesome Inserttag
<?php
// Example: {{icon::fa-phone} }
// src/EventListener/IconInsertTagListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('replaceInsertTags')]
class IconInsertTagListener
{
public const TAG = 'icon';
public function __invoke(string $tag)
{
$chunks = explode('::', $tag);
if (self::TAG !== $chunks[0]) {
return false;
}
if(strpos($chunks[1], "fa-") !== false ) {
return "<i class=\"fa " . $chunks[1] . "\"></i>";
}
return false;
}
}