From b3068f03c5ae09bd5215c6c4b6d63ef14ee8f029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Fri, 6 Sep 2024 13:25:06 +0200 Subject: [PATCH] Fix deprecation in Twig 3.12 --- .../LayoutsBundle/Templating/Twig/Node/DefaultContext.php | 5 ++++- bundles/LayoutsBundle/Templating/Twig/Node/RenderZone.php | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bundles/LayoutsBundle/Templating/Twig/Node/DefaultContext.php b/bundles/LayoutsBundle/Templating/Twig/Node/DefaultContext.php index 2110eeeac..984295047 100644 --- a/bundles/LayoutsBundle/Templating/Twig/Node/DefaultContext.php +++ b/bundles/LayoutsBundle/Templating/Twig/Node/DefaultContext.php @@ -6,6 +6,7 @@ use Twig\Attribute\YieldReady; use Twig\Compiler; +use Twig\Environment; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Node; @@ -14,7 +15,9 @@ final class DefaultContext extends Node { public function __construct(AbstractExpression $expr, int $line = 0, ?string $tag = null) { - parent::__construct(['expr' => $expr], [], $line, $tag); + Environment::MAJOR_VERSION === 3 && Environment::MINOR_VERSION < 12 ? + parent::__construct(['expr' => $expr], [], $line, $tag) : + parent::__construct(['expr' => $expr], [], $line); } public function compile(Compiler $compiler): void diff --git a/bundles/LayoutsBundle/Templating/Twig/Node/RenderZone.php b/bundles/LayoutsBundle/Templating/Twig/Node/RenderZone.php index 3ddeca6b1..cf7a3e2a2 100644 --- a/bundles/LayoutsBundle/Templating/Twig/Node/RenderZone.php +++ b/bundles/LayoutsBundle/Templating/Twig/Node/RenderZone.php @@ -26,7 +26,9 @@ public function __construct(AbstractExpression $zone, ?AbstractExpression $conte $nodes['context'] = $context; } - parent::__construct($nodes, [], $line, $tag); + Environment::MAJOR_VERSION === 3 && Environment::MINOR_VERSION < 12 ? + parent::__construct($nodes, [], $line, $tag) : + parent::__construct($nodes, [], $line); } public function compile(Compiler $compiler): void