Skip to content

Commit

Permalink
moved to JsonLd
Browse files Browse the repository at this point in the history
  • Loading branch information
ili101 committed Jul 1, 2024
1 parent 7f48307 commit ad132ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/JsonLd/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,14 @@ public function denormalize(mixed $data, string $class, ?string $format = null,

return parent::denormalize($data, $class, $format, $context);
}

protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false): array|bool
{
$allowedAttributes = parent::getAllowedAttributes($classOrObject, $context, $attributesAsString);
if (\is_array($allowedAttributes) && ($context['api_denormalize'] ?? false)) {
$allowedAttributes = array_merge($allowedAttributes, ['@id', '@type', '@context']);
}

return $allowedAttributes;
}
}
3 changes: 0 additions & 3 deletions src/Serializer/AbstractItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,6 @@ protected function getAllowedAttributes(string|object $classOrObject, array $con
$propertyNames = $this->propertyNameCollectionFactory->create($resourceClass, $options);

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

Expand Down

0 comments on commit ad132ad

Please sign in to comment.