Skip to content

Commit a7c6662

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: Move doctrine/annotations instructions
2 parents 2ebdb50 + 29b0fab commit a7c6662

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/serializer.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,13 @@ when constructing the normalizer::
180180
</person>
181181
EOF;
182182

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);
186185
$normalizer = new ObjectNormalizer($classMetadataFactory);
187186
$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
188190
$person = $serializer->deserialize($data, 'App\Model\Person', 'xml', [
189191
'allow_extra_attributes' => false,
190192
]);
@@ -368,8 +370,6 @@ You are now able to serialize only attributes in the groups you want::
368370
);
369371
// $obj2 = MyObj(foo: 'foo', bar: 'bar')
370372

371-
.. include:: /_includes/_annotation_loader_tip.rst.inc
372-
373373
.. _ignoring-attributes-when-serializing:
374374

375375
Selecting Specific Attributes

0 commit comments

Comments
 (0)