Skip to content

Commit b374d72

Browse files
SimperfitAmrouche Hamza
authored andcommitted
feature: add the context key documentation and link to encoders documentation in serializer
1 parent 5bb7c53 commit b374d72

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

components/serializer.rst

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -605,23 +605,7 @@ There are several types of normalizers available:
605605
Encoders
606606
--------
607607

608-
The Serializer component supports many formats out of the box:
609-
610-
:class:`Symfony\\Component\\Serializer\\Encoder\\JsonEncoder`
611-
This class encodes and decodes data in JSON_.
612-
613-
:class:`Symfony\\Component\\Serializer\\Encoder\\XmlEncoder`
614-
This class encodes and decodes data in XML_.
615-
616-
:class:`Symfony\\Component\\Serializer\\Encoder\\YamlEncoder`
617-
This encoder encodes and decodes data in YAML_. This encoder requires the
618-
:doc:`Yaml Component </components/yaml>`.
619-
620-
:class:`Symfony\\Component\\Serializer\\Encoder\\CsvEncoder`
621-
This encoder encodes and decodes data in CSV_.
622-
623-
All these encoders are enabled by default when using the Symfony Standard Edition
624-
with the serializer enabled.
608+
Please see :doc:`the encoders documentation </serializer/encoders.rst>`.
625609

626610
.. _component-serializer-handling-circular-references:
627611

serializer/encoders.rst

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,35 @@ Built-in Encoders
2525

2626
The Serializer component provides built-in encoders:
2727

28-
* :class:`Symfony\\Component\\Serializer\\Encoder\\CsvEncoder` to encode/decode CSV
29-
* :class:`Symfony\\Component\\Serializer\\Encoder\\JsonEncoder` to encode/decode JSON
30-
* :class:`Symfony\\Component\\Serializer\\Encoder\\XmlEncoder` to encode/decode XML
31-
* :class:`Symfony\\Component\\Serializer\\Encoder\\YamlEncoder` to encode/decode Yaml
28+
:class:`Symfony\\Component\\Serializer\\Encoder\\JsonEncoder`
29+
This class encodes and decodes data in JSON_.
30+
31+
:class:`Symfony\\Component\\Serializer\\Encoder\\XmlEncoder`
32+
This class encodes and decodes data in XML_.
33+
34+
:class:`Symfony\\Component\\Serializer\\Encoder\\YamlEncoder`
35+
This encoder encodes and decodes data in YAML_. This encoder requires the
36+
:doc:`Yaml Component </components/yaml>`.
37+
38+
:class:`Symfony\\Component\\Serializer\\Encoder\\CsvEncoder`
39+
This encoder encodes and decodes data in CSV_.
40+
41+
All these encoders are enabled by default when using the Symfony Standard Edition
42+
with the serializer enabled.
3243

3344
The ``JsonEncoder``
3445
~~~~~~~~~~~~~~~~~~~
3546

3647
The ``JsonEncoder`` encodes to and decodes from JSON strings, based on the PHP
3748
:phpfunction:`json_encode` and :phpfunction:`json_decode` functions.
3849

50+
The ``CsvEncoder``
51+
~~~~~~~~~~~~~~~~~~~
52+
53+
The ``CsvEncoder`` encodes to and decodes from CSV.
54+
55+
You can pass the context key ``as_collection`` in order to have the results always as a collection.
56+
3957
The ``XmlEncoder``
4058
~~~~~~~~~~~~~~~~~~
4159

@@ -64,6 +82,8 @@ Be aware that this encoder will consider keys beginning with ``@`` as attributes
6482
// <foo bar="value" />
6583
// </response>
6684

85+
You can pass the context key ``as_collection`` in order to have the results always as a collection.
86+
6787
The ``YamlEncoder``
6888
~~~~~~~~~~~~~~~~~~~
6989

0 commit comments

Comments
 (0)