Spaces:
No application file
No application file
| declare(strict_types=1); | |
| namespace Mautic\CoreBundle\Twig\Extension; | |
| use Twig\Extension\AbstractExtension; | |
| use Twig\TwigFunction; | |
| use Twig\TwigTest; | |
| /** | |
| * Helper for getting a class reference from a Twig template. | |
| */ | |
| class ClassExtension extends AbstractExtension | |
| { | |
| /** | |
| * @return TwigFunction[] | |
| */ | |
| public function getFunctions(): array | |
| { | |
| return [ | |
| new TwigFunction('get_class', fn ($value) => (new \ReflectionClass($value))->getShortName()), | |
| ]; | |
| } | |
| /** | |
| * @return TwigTest[] | |
| */ | |
| public function getTests(): array | |
| { | |
| return [ | |
| new TwigTest('instanceof', fn ($value, $class) => $value instanceof $class), | |
| ]; | |
| } | |
| } | |