From 14a0c2b4fdf2c8deda276ef9375e03961caee2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 22 Dec 2025 15:29:05 +0100 Subject: [PATCH] Refactor `WidgetRenderingTwig`: remove `TwigFunction` usage, replace with attributes for declaring functions. --- .../Templating/Widget/WidgetRenderingTwig.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php b/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php index ac5581a6b..bda51f4f3 100644 --- a/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php +++ b/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Templating\Events\DelegatedBlockRenderingEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Twig\DeprecatedCallableInfo; use Twig\Environment; -use Twig\TwigFunction; /** * Add the function `chill_delegated_block`. @@ -83,27 +82,13 @@ class WidgetRenderingTwig $this->widget[$place][$ordering] = [$widget, $config]; } - public function getFunctions(): array - { - return [ - new TwigFunction( - 'chill_delegated_block', - $this->renderingWidget(...), - [ - 'is_safe' => ['html'], - 'needs_environment' => true, - 'deprecated' => true, 'alternative' => 'chill_widget', - ] - ), - ]; - } - public function getName() { return 'chill_main_widget'; } - #[\Twig\Attribute\AsTwigFunction('chill_widget', needsEnvironment: true, isSafe: ['html'], deprecationInfo: new DeprecatedCallableInfo('chill-project/chill-bundles', '3.0'))] + #[\Twig\Attribute\AsTwigFunction('chill_widget', needsEnvironment: true, isSafe: ['html'])] + #[\Twig\Attribute\AsTwigFunction('chill_delegated_block', needsEnvironment: true, isSafe: ['html'], deprecationInfo: new DeprecatedCallableInfo('chill-project/chill-bundles', '3.0'))] public function renderingWidget(Environment $env, $block, array $context = []): string { // get the content of widgets