From 1dbb7e0fc8c465bcecc2b27ea8ab6a62959ecfad Mon Sep 17 00:00:00 2001 From: Evert Harmeling Date: Thu, 8 Feb 2024 12:53:40 +0100 Subject: [PATCH] [StimulusBundle] Set "use_yield" option to fix deprecation message --- src/StimulusBundle/src/Helper/StimulusHelper.php | 4 +++- src/StimulusBundle/tests/Dto/StimulusAttributesTest.php | 4 +++- src/TwigComponent/tests/Unit/ComponentAttributesTest.php | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/StimulusBundle/src/Helper/StimulusHelper.php b/src/StimulusBundle/src/Helper/StimulusHelper.php index a433caf1f08..a292e2f0051 100644 --- a/src/StimulusBundle/src/Helper/StimulusHelper.php +++ b/src/StimulusBundle/src/Helper/StimulusHelper.php @@ -27,7 +27,9 @@ final class StimulusHelper public function __construct(?Environment $twig) { // Twig needed just for its escaping mechanism - $this->twig = $twig ?? new Environment(new ArrayLoader()); + $this->twig = $twig ?? new Environment(new ArrayLoader(), [ + 'use_yield' => true, + ]); } public function createStimulusAttributes(): StimulusAttributes diff --git a/src/StimulusBundle/tests/Dto/StimulusAttributesTest.php b/src/StimulusBundle/tests/Dto/StimulusAttributesTest.php index 7d76ebe239e..1039ed17b8f 100644 --- a/src/StimulusBundle/tests/Dto/StimulusAttributesTest.php +++ b/src/StimulusBundle/tests/Dto/StimulusAttributesTest.php @@ -24,7 +24,9 @@ final class StimulusAttributesTest extends TestCase protected function setUp(): void { - $this->stimulusAttributes = new StimulusAttributes(new Environment(new ArrayLoader())); + $this->stimulusAttributes = new StimulusAttributes(new Environment(new ArrayLoader(), [ + 'use_yield' => true, + ])); } public function testAddAction(): void diff --git a/src/TwigComponent/tests/Unit/ComponentAttributesTest.php b/src/TwigComponent/tests/Unit/ComponentAttributesTest.php index 35fcb5b7d76..b24a93cb124 100644 --- a/src/TwigComponent/tests/Unit/ComponentAttributesTest.php +++ b/src/TwigComponent/tests/Unit/ComponentAttributesTest.php @@ -133,7 +133,9 @@ public function testCanAddStimulusControllerViaStimulusAttributes(): void 'data-live-data-value' => '{}', ]); - $stimulusAttributes = new StimulusAttributes(new Environment(new ArrayLoader())); + $stimulusAttributes = new StimulusAttributes(new Environment(new ArrayLoader(), [ + 'use_yield' => true, + ])); $stimulusAttributes->addController('foo', ['name' => 'ryan', 'some_array' => ['a', 'b']]); $attributes = $attributes->defaults($stimulusAttributes); @@ -158,7 +160,9 @@ public function testCanAddStimulusActionViaStimulusAttributes(): void 'data-action' => 'live#foo', ]); - $stimulusAttributes = new StimulusAttributes(new Environment(new ArrayLoader())); + $stimulusAttributes = new StimulusAttributes(new Environment(new ArrayLoader(), [ + 'use_yield' => true, + ])); $stimulusAttributes->addAction('foo', 'barMethod'); $attributes = $attributes->defaults([...$stimulusAttributes]);