Skip to content

Commit 2771a06

Browse files
committed
Add missing @id property
1 parent 8ba007b commit 2771a06

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Hydra/Serializer/CollectionNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function normalize($object, $format = null, array $context = [])
9090
$data['hydra:member'] = [];
9191
$iriOnly = $context[self::IRI_ONLY] ?? $this->defaultContext[self::IRI_ONLY];
9292
foreach ($object as $obj) {
93-
$data['hydra:member'][] = $iriOnly ? $this->iriConverter->getIriFromItem($obj) : $this->normalizer->normalize($obj, $format, $context);
93+
$data['hydra:member'][] = $iriOnly ? ['@id' => $this->iriConverter->getIriFromItem($obj)] : $this->normalizer->normalize($obj, $format, $context);
9494
}
9595

9696
$paginated = null;

tests/Hydra/Serializer/CollectionNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ public function testNormalizeIriOnlyResourceCollection(): void
368368
'@id' => '/foos',
369369
'@type' => 'hydra:Collection',
370370
'hydra:member' => [
371-
'/foos/1',
372-
'/foos/3',
371+
['@id' => '/foos/1'],
372+
['@id' => '/foos/3'],
373373
],
374374
'hydra:totalItems' => 2,
375375
], $actual);

0 commit comments

Comments
 (0)