From 0d42ed9262e341c50bff11fb81d5b7e15627ba2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 19 Dec 2025 11:56:44 +0100 Subject: [PATCH] Refactor `ChillTwigRoutingHelper` to extend `AbstractExtension` and register Twig filters properly --- .../Templating/ChillTwigRoutingHelper.php | 10 ++++++++-- .../ChillMainBundle/config/services/templating.yaml | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php index 588c77838..ae0d71a4d 100644 --- a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php @@ -23,7 +23,7 @@ use Twig\TwigFunction; * * The logic of the function is based on the original routing extension. */ -class ChillTwigRoutingHelper +class ChillTwigRoutingHelper extends AbstractExtension { /** * @var RoutingExtension @@ -75,7 +75,13 @@ class ChillTwigRoutingHelper return $this->originalExtension->getPath($name, $params, $relative); } - #[\Twig\Attribute\AsTwigFilter('chill_return_path_label')] + public function getFilters(): array + { + return [ + new TwigFilter('chill_return_path_label', $this->getLabelReturnPath(...)), + ]; + } + public function getLabelReturnPath($default) { $request = $this->requestStack->getCurrentRequest(); diff --git a/src/Bundle/ChillMainBundle/config/services/templating.yaml b/src/Bundle/ChillMainBundle/config/services/templating.yaml index ee56ba8f6..1e73771a5 100644 --- a/src/Bundle/ChillMainBundle/config/services/templating.yaml +++ b/src/Bundle/ChillMainBundle/config/services/templating.yaml @@ -29,6 +29,8 @@ services: $originalExtension: '@twig.extension.routing' autoconfigure: true autowire: true + tags: + - { name: twig.extension } Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension: autoconfigure: true