mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-02 03:59:40 +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:
@@ -13,8 +13,8 @@ namespace Chill\MainBundle\Templating\Widget;
|
||||
|
||||
use Chill\MainBundle\Templating\Events\DelegatedBlockRenderingEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Twig\DeprecatedCallableInfo;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ use Twig\TwigFunction;
|
||||
* `Chill\MainBundle\Templating\Events\DelegatedBlockRenderingEvent`
|
||||
* for usage of this event class
|
||||
*/
|
||||
class WidgetRenderingTwig extends AbstractExtension
|
||||
class WidgetRenderingTwig
|
||||
{
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
@@ -83,8 +83,7 @@ class WidgetRenderingTwig extends AbstractExtension
|
||||
$this->widget[$place][$ordering] = [$widget, $config];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getFunctions()
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction(
|
||||
@@ -96,11 +95,6 @@ class WidgetRenderingTwig extends AbstractExtension
|
||||
'deprecated' => true, 'alternative' => 'chill_widget',
|
||||
]
|
||||
),
|
||||
new TwigFunction(
|
||||
'chill_widget',
|
||||
$this->renderingWidget(...),
|
||||
['is_safe' => ['html'], 'needs_environment' => true]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -109,7 +103,8 @@ class WidgetRenderingTwig extends AbstractExtension
|
||||
return 'chill_main_widget';
|
||||
}
|
||||
|
||||
public function renderingWidget(Environment $env, $block, array $context = [])
|
||||
#[\Twig\Attribute\AsTwigFunction('chill_widget', 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
|
||||
$content = '';
|
||||
|
||||
Reference in New Issue
Block a user