function AbstractObjectNormalizer::updateData
Sets an attribute and apply the name converter if necessary.
1 call to AbstractObjectNormalizer::updateData()
- AbstractObjectNormalizer::normalize in vendor/
symfony/ serializer/ Normalizer/ AbstractObjectNormalizer.php - Normalizes data into a set of arrays/scalars.
File
-
vendor/
symfony/ serializer/ Normalizer/ AbstractObjectNormalizer.php, line 999
Class
- AbstractObjectNormalizer
- Base class for a normalizer dealing with objects.
Namespace
Symfony\Component\Serializer\NormalizerCode
private function updateData(array $data, string $attribute, mixed $attributeValue, string $class, ?string $format, array $context, ?array $attributesMetadata, ?ClassMetadataInterface $classMetadata) : array {
if (null === $attributeValue && ($context[self::SKIP_NULL_VALUES] ?? $this->defaultContext[self::SKIP_NULL_VALUES] ?? false)) {
return $data;
}
if (null !== $classMetadata && null !== ($serializedPath = ($attributesMetadata[$attribute] ?? null)?->getSerializedPath())) {
$propertyAccessor = PropertyAccess::createPropertyAccessor();
if ($propertyAccessor->isReadable($data, $serializedPath) && null !== $propertyAccessor->getValue($data, $serializedPath)) {
throw new LogicException(\sprintf('The element you are trying to set is already populated: "%s".', (string) $serializedPath));
}
$propertyAccessor->setValue($data, $serializedPath, $attributeValue);
return $data;
}
if ($this->nameConverter) {
$attribute = $this->nameConverter
->normalize($attribute, $class, $format, $context);
}
$data[$attribute] = $attributeValue;
return $data;
}