Skip to content

Commit cb64101

Browse files
committed
edit
1 parent 4e5741c commit cb64101

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/JsonLd/Serializer/ItemNormalizer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ public function normalize(mixed $object, ?string $format = null, array $context
124124
unset($context['operation'], $context['operation_name']);
125125
}
126126

127-
$operation = $context['operation'] ?? null;
127+
$operation = null;
128+
if ($isResourceClass) {
129+
$operation = $context['operation'] ?? $this->resourceMetadataCollectionFactory->create($resourceClass)->getOperation();
130+
}
131+
128132
if (true === ($context['output']['gen_id'] ?? true) && true === ($context['force_iri_generation'] ?? true) && $iri = $this->iriConverter->getIriFromResource($object, $operation?->getUrlGenerationStrategy() ?? UrlGeneratorInterface::ABS_PATH, $operation, $context)) {
129133
$context['iri'] = $iri;
130134
$metadata['@id'] = $iri;
@@ -138,8 +142,6 @@ public function normalize(mixed $object, ?string $format = null, array $context
138142
}
139143

140144
if (!isset($metadata['@type']) && $isResourceClass) {
141-
$operation = $context['operation'] ?? $this->resourceMetadataCollectionFactory->create($resourceClass)->getOperation();
142-
143145
$types = $operation instanceof HttpOperation ? $operation->getTypes() : null;
144146
if (null === $types) {
145147
$types = [$operation->getShortName()];

0 commit comments

Comments
 (0)