File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -180,17 +180,17 @@ when constructing the normalizer::
180
180
</person>
181
181
EOF;
182
182
183
- // this will throw a Symfony\Component\Serializer\Exception\ExtraAttributesException
184
- // because "city" is not an attribute of the Person class
185
- $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
183
+ // $loader is any of the valid loaders explained later in this article
184
+ $classMetadataFactory = new ClassMetadataFactory($loader);
186
185
$normalizer = new ObjectNormalizer($classMetadataFactory);
187
186
$serializer = new Serializer([$normalizer]);
187
+
188
+ // this will throw a Symfony\Component\Serializer\Exception\ExtraAttributesException
189
+ // because "city" is not an attribute of the Person class
188
190
$person = $serializer->deserialize($data, 'App\Model\Person', 'xml', [
189
191
'allow_extra_attributes' => false,
190
192
]);
191
193
192
- .. include :: /_includes/_annotation_loader_tip.rst.inc
193
-
194
194
Deserializing in an Existing Object
195
195
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
196
196
You can’t perform that action at this time.
0 commit comments