@@ -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
@@ -1533,10 +1555,9 @@ Instead of throwing an exception, a custom callable can be executed when the
1533
1555
maximum depth is reached. This is especially useful when serializing entities
1534
1556
having unique identifiers::
1535
1557
1536
- use Doctrine\Common\Annotations\AnnotationReader;
1537
1558
use Symfony\Component\Serializer\Annotation\MaxDepth;
1538
1559
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1539
- use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader ;
1560
+ use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader ;
1540
1561
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
1541
1562
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1542
1563
use Symfony\Component\Serializer\Serializer;
@@ -1560,7 +1581,7 @@ having unique identifiers::
1560
1581
$level3->id = 3;
1561
1582
$level2->child = $level3;
1562
1583
1563
- $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader() ));
1584
+ $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader( ));
1564
1585
1565
1586
// all callback parameters are optional (you can omit the ones you don't use)
1566
1587
$maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, string $format = null, array $context = []): string {
@@ -1761,7 +1782,7 @@ this is already set up and you only need to provide the configuration. Otherwise
1761
1782
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1762
1783
use Symfony\Component\Serializer\Serializer;
1763
1784
1764
- $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader() ));
1785
+ $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader( ));
1765
1786
1766
1787
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
1767
1788
0 commit comments