Skip to content

Commit 1fe2ae3

Browse files
committed
[Stimulus] Use Twig >3.9 'EscaperRuntime'
Solve CI deprecations
1 parent 3962582 commit 1fe2ae3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/StimulusBundle/src/Dto/StimulusAttributes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use Twig\Environment;
1717
use Twig\Extension\EscaperExtension;
18+
use Twig\Runtime\EscaperRuntime;
1819

1920
/**
2021
* Helper to build Stimulus-related HTML attributes.
@@ -215,6 +216,10 @@ private function getFormattedValue(mixed $value): string
215216

216217
private function escapeAsHtmlAttr(mixed $value): string
217218
{
219+
if (class_exists(EscaperRuntime::class)) {
220+
return $this->env->getRuntime(EscaperRuntime::class)->escape($value, 'html_attr');
221+
}
222+
218223
if (method_exists(EscaperExtension::class, 'escape')) {
219224
return EscaperExtension::escape($this->env, $value, 'html_attr');
220225
}

0 commit comments

Comments
 (0)