File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 12
12
namespace Symfony \UX \LiveComponent \Util ;
13
13
14
14
use Twig \Environment ;
15
+ use Twig \Extension \EscaperExtension ;
15
16
16
17
/**
17
18
* An array of attributes that can eventually be returned as an escaped array.
@@ -99,6 +100,11 @@ public function setBrowserEventsToDispatch(array $browserEventsToDispatch): void
99
100
100
101
private function escapeAttribute (string $ value ): string
101
102
{
102
- return twig_escape_filter ($ this ->twig , $ value , 'html_attr ' );
103
+ if (method_exists (EscaperExtension::class, 'escape ' )) {
104
+ return EscaperExtension::escape ($ this ->twig , $ value , 'html_attr ' );
105
+ }
106
+
107
+ // since twig/twig 3.9.0: Using the internal "twig_escape_filter" function is deprecated.
108
+ return (string ) twig_escape_filter ($ this ->twig , $ value , 'html_attr ' );
103
109
}
104
110
}
Original file line number Diff line number Diff line change 14
14
namespace Symfony \UX \StimulusBundle \Dto ;
15
15
16
16
use Twig \Environment ;
17
+ use Twig \Extension \EscaperExtension ;
17
18
18
19
/**
19
20
* Helper to build Stimulus-related HTML attributes.
@@ -214,6 +215,11 @@ private function getFormattedValue(mixed $value): string
214
215
215
216
private function escapeAsHtmlAttr (mixed $ value ): string
216
217
{
218
+ if (method_exists (EscaperExtension::class, 'escape ' )) {
219
+ return EscaperExtension::escape ($ this ->env , $ value , 'html_attr ' );
220
+ }
221
+
222
+ // since twig/twig 3.9.0: Using the internal "twig_escape_filter" function is deprecated.
217
223
return (string ) twig_escape_filter ($ this ->env , $ value , 'html_attr ' );
218
224
}
219
225
You can’t perform that action at this time.
0 commit comments