From 75516f0bdc54a7449bc08a5a026a7d73da8b0c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Fri, 17 May 2024 11:05:35 +0200 Subject: [PATCH] [LiveComponent] Fix EscaperRuntime deprecation --- src/LiveComponent/src/Util/LiveAttributesCollection.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/LiveComponent/src/Util/LiveAttributesCollection.php b/src/LiveComponent/src/Util/LiveAttributesCollection.php index 21c9433be7e..64d6e7342a6 100644 --- a/src/LiveComponent/src/Util/LiveAttributesCollection.php +++ b/src/LiveComponent/src/Util/LiveAttributesCollection.php @@ -13,6 +13,7 @@ use Twig\Environment; use Twig\Extension\EscaperExtension; +use Twig\Runtime\EscaperRuntime; /** * An array of attributes that can eventually be returned as an escaped array. @@ -114,6 +115,10 @@ public function setQueryUrlMapping(array $queryUrlMapping): void private function escapeAttribute(string $value): string { + if (class_exists(EscaperRuntime::class)) { + return $this->twig->getRuntime(EscaperRuntime::class)->escape($value, 'html_attr'); + } + if (method_exists(EscaperExtension::class, 'escape')) { return EscaperExtension::escape($this->twig, $value, 'html_attr'); }