Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Closed
Description
Serializer's documentation explains that we can specify a context specific to normalization or denormalization usingnormalizationContext
anddenormalizationContext
keys in Yaml configuration:
https://github.com/symfony/symfony-docs/blob/6.4/serializer.rst?plain=1#L523-L524
# config/serializer/person.yamlApp\Model\Person:attributes:createdAt:contexts: -normalizationContext:{ datetime_format: 'Y-m-d' }denormalizationContext:{ datetime_format: !php/const \DateTime::RFC3339 }
In the other hand, theYamlFileLoader
is looking fornormalization_context
anddenormalization_context
keys:
if ($context =$line['normalization_context'] ??false) {$attributeMetadata->setNormalizationContextForGroups($context,$groups);}if ($context =$line['denormalization_context'] ??false) {$attributeMetadata->setDenormalizationContextForGroups($context,$groups);}
Links above are for6.4
but it seems to be there from the beginning, nothing changed in the code. Confusion may be due to the name of the corresponding attribute.