@@ -249,23 +249,30 @@ The definition of serialization can be specified using annotations, XML
249
249
or YAML. The :class: `Symfony\\ Component\\ Serializer\\ Mapping\\ Factory\\ ClassMetadataFactory `
250
250
that will be used by the normalizer must be aware of the format to use.
251
251
252
- Initialize the :class: `Symfony\\ Component\\ Serializer\\ Mapping\\ Factory\\ ClassMetadataFactory `
253
- like the following::
252
+ The following code shows how to initialize the :class: `Symfony\\ Component\\ Serializer\\ Mapping\\ Factory\\ ClassMetadataFactory `
253
+ for each format:
254
+
255
+ * Annotations in PHP files::
254
256
255
- use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
256
- // For annotations
257
257
use Doctrine\Common\Annotations\AnnotationReader;
258
+ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
258
259
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
259
- // For XML
260
- // use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
261
- // For YAML
262
- // use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
263
260
264
261
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
265
- // For XML
266
- // $classMetadataFactory = new ClassMetadataFactory(new XmlFileLoader('/path/to/your/definition.xml'));
267
- // For YAML
268
- // $classMetadataFactory = new ClassMetadataFactory(new YamlFileLoader('/path/to/your/definition.yml'));
262
+
263
+ * XML files::
264
+
265
+ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
266
+ use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
267
+
268
+ $classMetadataFactory = new ClassMetadataFactory(new XmlFileLoader('/path/to/your/definition.xml'));
269
+
270
+ * YAML files::
271
+
272
+ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
273
+ use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
274
+
275
+ $classMetadataFactory = new ClassMetadataFactory(new YamlFileLoader('/path/to/your/definition.yml'));
269
276
270
277
.. _component-serializer-attributes-groups-annotations :
271
278
0 commit comments