Skip to content

Commit c67d907

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Merge encoder sections and show options in a table
2 parents ffcd049 + 59bee3e commit c67d907

File tree

1 file changed

+40
-60
lines changed

1 file changed

+40
-60
lines changed

components/serializer.rst

+40-60
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,34 @@ The ``CsvEncoder``
797797

798798
The ``CsvEncoder`` encodes to and decodes from CSV.
799799

800+
The ``CsvEncoder`` Context Options
801+
..................................
802+
803+
The ``encode()`` method defines a third optional parameter called ``context``
804+
which defines the configuration options for the CsvEncoder an associative array::
805+
806+
$csvEncoder->encode($array, 'csv', $context);
807+
808+
These are the options available:
809+
810+
======================= ==================================================== ==========================
811+
Option Description Default
812+
======================= ==================================================== ==========================
813+
``csv_delimiter`` Sets the field delimiter separating values (one ``,``
814+
character only)
815+
``csv_enclosure`` Sets the field enclosure (one character only) ``"``
816+
``csv_escape_char`` Sets the escape character (at most one character)
817+
``csv_key_separator`` Sets the separator for array's keys during its ``.``
818+
flattening
819+
``csv_headers`` Sets the headers for the data ``[]``, inferred from input data's keys
820+
``csv_escape_formulas`` Escapes fields containg formulas by prepending them ``false``
821+
with a ``\t`` character
822+
``as_collection`` Always returns results as a collection, even if only
823+
one line is decoded.
824+
``no_headers`` Disables header in the encoded CSV ``false``
825+
``output_utf8_bom`` Outputs special `UTF-8 BOM`_ along with encoded data ``false``
826+
======================= ==================================================== ==========================
827+
800828
The ``XmlEncoder``
801829
~~~~~~~~~~~~~~~~~~
802830

@@ -864,23 +892,18 @@ which defines the configuration options for the XmlEncoder an associative array:
864892

865893
These are the options available:
866894

867-
``xml_format_output``
868-
If set to true, formats the generated XML with line breaks and indentation.
869-
870-
``xml_version``
871-
Sets the XML version attribute (default: ``1.1``).
872-
873-
``xml_encoding``
874-
Sets the XML encoding attribute (default: ``utf-8``).
875-
876-
``xml_standalone``
877-
Adds standalone attribute in the generated XML (default: ``true``).
878-
879-
``xml_root_node_name``
880-
Sets the root node name (default: ``response``).
881-
882-
``remove_empty_tags``
883-
If set to true, removes all empty tags in the generated XML (default: ``false``).
895+
====================== ==================================================== ==========================
896+
Option Description Default
897+
====================== ==================================================== ==========================
898+
``xml_format_output`` If set to true, formats the generated XML with line
899+
breaks and indentation.
900+
``xml_version`` Sets the XML version attribute ``1.1``
901+
``xml_encoding`` Sets the XML encoding attribute ``utf-8``
902+
``xml_standalone`` Adds standalone attribute in the generated XML ``true``
903+
``xml_root_node_name`` Sets the root node name (default: ``response``).
904+
``remove_empty_tags`` If set to true, removes all empty tags in the ``false``
905+
generated XML
906+
====================== ==================================================== ==========================
884907

885908
The ``YamlEncoder``
886909
~~~~~~~~~~~~~~~~~~~
@@ -1193,49 +1216,6 @@ you indicate that you're expecting an array instead of a single object::
11931216
$data = ...; // The serialized data from the previous example
11941217
$persons = $serializer->deserialize($data, 'Acme\Person[]', 'json');
11951218

1196-
1197-
The ``CsvEncoder``
1198-
------------------
1199-
1200-
This encoder transforms arrays into CSV and vice versa.
1201-
1202-
Context
1203-
~~~~~~~
1204-
1205-
The ``encode()`` method defines a third optional parameter called ``context``
1206-
which defines the configuration options for the CsvEncoder an associative array::
1207-
1208-
$csvEncoder->encode($array, 'csv', $context);
1209-
1210-
These are the options available:
1211-
1212-
``csv_delimiter``
1213-
Sets the field delimiter separating values (one character only, default: ``,``).
1214-
1215-
``csv_enclosure``
1216-
Sets the field enclosure (one character only, default: ``"``).
1217-
1218-
``csv_escape_char``
1219-
Sets the escape character (at most one character, default: empty string).
1220-
1221-
``csv_key_separator``
1222-
Sets the separator for array's keys during its flattening (default: ``.``).
1223-
1224-
``csv_headers``
1225-
Sets the headers for the data (default: ``[]``, inferred from input data's keys).
1226-
1227-
``csv_escape_formulas``
1228-
Escapes fields containg formulas by prepending them with a ``\t`` character (default: ``false``).
1229-
1230-
``as_collection``
1231-
Always returns results as a collection, even if only one line is decoded.
1232-
1233-
``no_headers``
1234-
Disables header in the encoded CSV (default: ``false``).
1235-
1236-
``output_utf8_bom``
1237-
Outputs special `UTF-8 BOM`_ along with encoded data (default: ``false``).
1238-
12391219
Handling Constructor Arguments
12401220
------------------------------
12411221

0 commit comments

Comments
 (0)