Part-DB-server/src/Twig/TypeLabelExtension.php
2020-08-21 22:43:37 +02:00

25 lines
665 B
PHP

<?php
namespace App\Twig;
use App\Services\ElementTypeNameGenerator;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
final class TypeLabelExtension extends AbstractExtension
{
private $nameGenerator;
public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator)
{
$this->nameGenerator = $elementTypeNameGenerator;
}
public function getFunctions(): array
{
return [
new TwigFunction('elementType', [$this->nameGenerator, 'getLocalizedTypeLabel']),
new TwigFunction('elementTypeName', [$this->nameGenerator, 'getTypeNameCombination']),
];
}
}