@@ -279,6 +279,13 @@ for each format:
279
279
280
280
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
281
281
282
+ * Attributes in PHP files::
283
+
284
+ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
285
+ use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
286
+
287
+ $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
288
+
282
289
* YAML files::
283
290
284
291
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
@@ -293,6 +300,21 @@ for each format:
293
300
294
301
$classMetadataFactory = new ClassMetadataFactory(new XmlFileLoader('/path/to/your/definition.xml'));
295
302
303
+ .. versionadded :: 6.4
304
+
305
+ The
306
+ :class: `Symfony\\ Component\\ Serializer\\ Mapping\\ Loader\\ AttributeLoader `
307
+ was introduced in Symfony 6.4. Prior to this, the
308
+ :class: `Symfony\\ Component\\ Serializer\\ Mapping\\ Loader\\ AnnotationLoader `
309
+ must be used.
310
+
311
+ .. deprecated :: 6.4
312
+
313
+ Reading annotations in PHP files is deprecated since Symfony 6.4.
314
+ Also, the
315
+ :class: `Symfony\\ Component\\ Serializer\\ Mapping\\ Loader\\ AnnotationLoader `
316
+ was deprecated in Symfony 6.4.
317
+
296
318
.. _component-serializer-attributes-groups-annotations :
297
319
.. _component-serializer-attributes-groups-attributes :
298
320
@@ -645,7 +667,7 @@ this is already set up and you only need to provide the configuration. Otherwise
645
667
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
646
668
use Symfony\Component\Serializer\Serializer;
647
669
648
- $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader() ));
670
+ $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader( ));
649
671
650
672
$metadataAwareNameConverter = new MetadataAwareNameConverter($classMetadataFactory);
651
673
@@ -1507,10 +1529,9 @@ Instead of throwing an exception, a custom callable can be executed when the
1507
1529
maximum depth is reached. This is especially useful when serializing entities
1508
1530
having unique identifiers::
1509
1531
1510
- use Doctrine\Common\Annotations\AnnotationReader;
1511
1532
use Symfony\Component\Serializer\Annotation\MaxDepth;
1512
1533
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1513
- use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader ;
1534
+ use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader ;
1514
1535
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
1515
1536
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1516
1537
use Symfony\Component\Serializer\Serializer;
@@ -1534,7 +1555,7 @@ having unique identifiers::
1534
1555
$level3->id = 3;
1535
1556
$level2->child = $level3;
1536
1557
1537
- $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader() ));
1558
+ $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader( ));
1538
1559
1539
1560
// all callback parameters are optional (you can omit the ones you don't use)
1540
1561
$maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, string $format = null, array $context = []): string {
@@ -1735,7 +1756,7 @@ this is already set up and you only need to provide the configuration. Otherwise
1735
1756
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1736
1757
use Symfony\Component\Serializer\Serializer;
1737
1758
1738
- $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader() ));
1759
+ $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader( ));
1739
1760
1740
1761
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
1741
1762
0 commit comments