mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-13 21:01:24 +00:00
Refactor WidgetRenderingTwig: remove TwigFunction usage, replace with attributes for declaring functions.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user