Skip to content

Commit 8a6e54b

Browse files
committed
Fix twig deprecation: twig_escape_filter
1 parent 8fe391d commit 8a6e54b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/LiveComponent/src/Util/LiveAttributesCollection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\UX\LiveComponent\Util;
1313

1414
use Twig\Environment;
15+
use Twig\Extension\EscaperExtension;
1516

1617
/**
1718
* An array of attributes that can eventually be returned as an escaped array.
@@ -99,6 +100,8 @@ public function setBrowserEventsToDispatch(array $browserEventsToDispatch): void
99100

100101
private function escapeAttribute(string $value): string
101102
{
102-
return twig_escape_filter($this->twig, $value, 'html_attr');
103+
$escapeExtension = new EscaperExtension();
104+
105+
return (string) $escapeExtension->escape($this->twig, $value, 'html_attr');
103106
}
104107
}

src/StimulusBundle/src/Dto/StimulusAttributes.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Symfony\UX\StimulusBundle\Dto;
1515

1616
use Twig\Environment;
17+
use Twig\Extension\EscaperExtension;
1718

1819
/**
1920
* Helper to build Stimulus-related HTML attributes.
@@ -214,7 +215,9 @@ private function getFormattedValue(mixed $value): string
214215

215216
private function escapeAsHtmlAttr(mixed $value): string
216217
{
217-
return (string) twig_escape_filter($this->env, $value, 'html_attr');
218+
$escapeExtension = new EscaperExtension();
219+
220+
return (string) $escapeExtension->escape($this->env, $value, 'html_attr');
218221
}
219222

220223
/**

0 commit comments

Comments
 (0)