8000 minor #11281 try to make the code examples less noisy (OskarStark) · symfony/symfony-docs@f40aa53 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 div class="prc-PageLayout-HeaderContent-dVIQb" style="--spacing:var(--spacing-normal)">

Commit f40aa53

Browse files
committed
minor #11281 try to make the code examples less noisy (OskarStark)
This PR was merged into the 3.4 branch. Discussion ---------- try to make the code examples less noisy <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 22497ec try to make the code examples less noisy
2 parents 6f1f6c0 + 22497ec commit f40aa53

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

components/serializer.rst

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,23 +249,30 @@ The definition of serialization can be specified using annotations, XML
249249
or YAML. The :class:`Symfony\\Component\\Serializer\\Mapping\\Factory\\ClassMetadataFactory`
250250
that will be used by the normalizer must be aware of the format to use.
251251

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::
254256

255-
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
256-
// For annotations
257257
use Doctrine\Common\Annotations\AnnotationReader;
258+
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
258259
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;
263260

264261
$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'));
269276

270277
.. _component-serializer-attributes-groups-annotations:
271278

0 commit comments

Comments
 (0)
0