mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-03 20:49:41 +00:00
Refactor ChillTwigRoutingHelper to extend AbstractExtension and register Twig filters properly
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -29,6 +29,8 @@ services:
|
||||
$originalExtension: '@twig.extension.routing'
|
||||
autoconfigure: true
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
|
||||
Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension:
|
||||
autoconfigure: true
|
||||
|
||||
Reference in New Issue
Block a user