Skip to content

Commit ad132ad

Browse files
committed
moved to JsonLd
1 parent 7f48307 commit ad132ad

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/JsonLd/Serializer/ItemNormalizer.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,14 @@ public function denormalize(mixed $data, string $class, ?string $format = null,
153153

154154
return parent::denormalize($data, $class, $format, $context);
155155
}
156+
157+
protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false): array|bool
158+
{
159+
$allowedAttributes = parent::getAllowedAttributes($classOrObject, $context, $attributesAsString);
160+
if (\is_array($allowedAttributes) && ($context['api_denormalize'] ?? false)) {
161+
$allowedAttributes = array_merge($allowedAttributes, ['@id', '@type', '@context']);
162+
}
163+
164+
return $allowedAttributes;
165+
}
156166
}

src/Serializer/AbstractItemNormalizer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,6 @@ protected function getAllowedAttributes(string|object $classOrObject, array $con
426426
$propertyNames = $this->propertyNameCollectionFactory->create($resourceClass, $options);
427427

428428
$allowedAttributes = [];
429-
if ($context['api_denormalize'] ?? false) {
430-
$allowedAttributes = ['@id', '@type', '@context'];
431-
}
432429
foreach ($propertyNames as $propertyName) {
433430
$propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName, $options);
434431

0 commit comments

Comments
 (0)