Skip to content

Commit

Permalink
feat(serializer): context IRI in HAL or JsonApi format (#6215)
Browse files Browse the repository at this point in the history
  • Loading branch information
pupaxxo committed May 24, 2024
1 parent 65296ea commit b47edb2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/Hal/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,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;
Expand Down
4 changes: 2 additions & 2 deletions src/JsonApi/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b47edb2

Please sign in to comment.