From 02dd82f4ee667eb501c9dfb1a79607ccd69b6801 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Mon, 15 Apr 2024 16:13:40 +0200 Subject: [PATCH] Add 'useCredentials' to ignored attributes in normalizers In the two updated classes (ManifestCompileEventListener and PwaDevServerSubscriber), the constant 'useCredentials' has been added to the IGNORED_ATTRIBUTES option of the Symfony AbstractNormalizer, which prevents serialization of this specific attribute. This adjustment was made to improve the efficiency of our serialization process. --- src/Subscriber/ManifestCompileEventListener.php | 2 ++ src/Subscriber/PwaDevServerSubscriber.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Subscriber/ManifestCompileEventListener.php b/src/Subscriber/ManifestCompileEventListener.php index eda62c5..dae83e6 100644 --- a/src/Subscriber/ManifestCompileEventListener.php +++ b/src/Subscriber/ManifestCompileEventListener.php @@ -10,6 +10,7 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\EventDispatcher\Attribute\AsEventListener; use Symfony\Component\Serializer\Encoder\JsonEncode; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Serializer\SerializerInterface; use const JSON_PRETTY_PRINT; @@ -40,6 +41,7 @@ public function __construct( $options = [ AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES => true, AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + AbstractNormalizer::IGNORED_ATTRIBUTES => ['useCredentials'], JsonEncode::OPTIONS => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR, ]; if ($debug === true) { diff --git a/src/Subscriber/PwaDevServerSubscriber.php b/src/Subscriber/PwaDevServerSubscriber.php index ef76b12..74e7294 100644 --- a/src/Subscriber/PwaDevServerSubscriber.php +++ b/src/Subscriber/PwaDevServerSubscriber.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\Serializer\Encoder\JsonEncode; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Serializer\SerializerInterface; use function assert; @@ -69,6 +70,7 @@ public function __construct( $options = [ AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES => true, AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + AbstractNormalizer::IGNORED_ATTRIBUTES => ['useCredentials'], JsonEncode::OPTIONS => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR, ]; if ($debug === true) {