Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] fix AbstractObjectNormalizer #46843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,10 @@ protected function getAttributeDenormalizationContext(string $class, string $att
return array_merge($context, $metadata->getDenormalizationContextForGroups($this->getGroups($context)));
}

private function getAttributeMetadata($objectOrClass, string $attribute): ?AttributeMetadataInterface
/**
* @internal
*/
protected function getAttributeMetadata(object|string $objectOrClass, string $attribute): ?AttributeMetadataInterface
{
if (!$this->classMetadataFactory) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,41 +226,6 @@ public function normalize(mixed $object, string $format = null, array $context =
return $data;
}

/**
* Computes the normalization context merged with current one. Metadata always wins over global context, as more specific.
*/
private function getAttributeNormalizationContext(object $object, string $attribute, array $context): array
{
if (null === $metadata = $this->getAttributeMetadata($object, $attribute)) {
return $context;
}

return array_merge($context, $metadata->getNormalizationContextForGroups($this->getGroups($context)));
}

/**
* Computes the denormalization context merged with current one. Metadata always wins over global context, as more specific.
*/
private function getAttributeDenormalizationContext(string $class, string $attribute, array $context): array
{
$context['deserialization_path'] = ($context['deserialization_path'] ?? false) ? $context['deserialization_path'].'.'.$attribute : $attribute;

if (null === $metadata = $this->getAttributeMetadata($class, $attribute)) {
return $context;
}

return array_merge($context, $metadata->getDenormalizationContextForGroups($this->getGroups($context)));
}

private function getAttributeMetadata(object|string $objectOrClass, string $attribute): ?AttributeMetadataInterface
{
if (!$this->classMetadataFactory) {
return null;
}

return $this->classMetadataFactory->getMetadataFor($objectOrClass)->getAttributesMetadata()[$attribute] ?? null;
}

/**
* {@inheritdoc}
*/
Expand Down