mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-15 05:41:25 +00:00
Refactor Twig extensions to use attributes for declaring functions and filters, remove AbstractExtension inheritance, and clean up related service definitions.
This commit is contained in:
@@ -17,31 +17,17 @@ use Twig\TwigFilter;
|
||||
/**
|
||||
* Class ChillEntityRenderExtension.
|
||||
*/
|
||||
class ChillEntityRenderExtension extends AbstractExtension
|
||||
class ChillEntityRenderExtension
|
||||
{
|
||||
public function __construct(private readonly ChillEntityRenderManagerInterface $renderManager) {}
|
||||
|
||||
/**
|
||||
* @return array|TwigFilter[]
|
||||
*/
|
||||
#[\Override]
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new TwigFilter('chill_entity_render_string', $this->renderString(...), [
|
||||
'is_safe' => ['html'],
|
||||
]),
|
||||
new TwigFilter('chill_entity_render_box', $this->renderBox(...), [
|
||||
'is_safe' => ['html'],
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Twig\Attribute\AsTwigFilter('chill_entity_render_box', isSafe: ['html'])]
|
||||
public function renderBox(?object $entity, array $options = []): string
|
||||
{
|
||||
return $this->renderManager->renderBox($entity, $options);
|
||||
}
|
||||
|
||||
#[\Twig\Attribute\AsTwigFilter('chill_entity_render_string', isSafe: ['html'])]
|
||||
public function renderString(?object $entity, array $options = []): string
|
||||
{
|
||||
return $this->renderManager->renderString($entity, $options);
|
||||
|
||||
Reference in New Issue
Block a user