Skip to content

Commit

Permalink
[StimulusBundle] Set "use_yield" option to fix deprecation message
Browse files Browse the repository at this point in the history
  • Loading branch information
evertharmeling committed Feb 8, 2024
1 parent 0143930 commit 1dbb7e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/StimulusBundle/src/Helper/StimulusHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/StimulusBundle/tests/Dto/StimulusAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/TwigComponent/tests/Unit/ComponentAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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]);

Expand Down

0 comments on commit 1dbb7e0

Please sign in to comment.