From 77c57fd188ec2b65f6c117706fee87e2f41f258b Mon Sep 17 00:00:00 2001 From: Andrea Ruggiero Date: Fri, 24 May 2024 08:56:46 +0200 Subject: [PATCH] feat(serializer): context IRI in HAL or JsonApi format (#6215) --- Serializer/ItemNormalizer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Serializer/ItemNormalizer.php b/Serializer/ItemNormalizer.php index e68bda8..84c15dd 100644 --- a/Serializer/ItemNormalizer.php +++ b/Serializer/ItemNormalizer.php @@ -94,8 +94,8 @@ public function normalize(mixed $object, ?string $format = null, array $context } $context = $this->initContext($resourceClass, $context); - $iri = $this->iriConverter->getIriFromResource($object, UrlGeneratorInterface::ABS_PATH, $context['operation'] ?? null, $context); - $context['iri'] = $iri; + + $iri = $context['iri'] ??= $this->iriConverter->getIriFromResource($object, UrlGeneratorInterface::ABS_PATH, $context['operation'] ?? null, $context); $context['object'] = $object; $context['format'] = $format; $context['api_normalize'] = true;