8000 Merge branch '5.1' into 5.x · symfony/symfony-docs@0c67f54 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0c67f54

Browse files
committed
Merge branch '5.1' into 5.x
* 5.1: Merge encoder sections and show options in a table
2 parents edf388d + c67d907 commit 0c67f54

File tree

1 file changed

+40
-60
lines changed

1 file changed

+40
-60
lines changed

components/serializer.rst

Lines changed: 40 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,34 @@ The ``CsvEncoder``
878878

879879
The ``CsvEncoder`` encodes to and decodes from CSV.
880880

881+
The ``CsvEncoder`` Context Options
882+
..................................
883+
884+
The ``encode()`` method defines a third optional parameter called ``context``
885+
which defines the configuration options for the CsvEncoder an associative array::
886+
887+
$csvEncoder->encode($array, 'csv', $context);
888+
889+
These are the options available:
890+
891+
======================= ==================================================== ==========================
892+
Option Description Default
893+
======================= ==================================================== ==========================
894+
``csv_delimiter`` Sets the field delimiter separating values (one ``,``
895+
character only)
896+
``csv_enclosure`` Sets the field enclosure (one character only) ``"``
897+
``csv_escape_char`` Sets the escape character (at most one character)
898+
``csv_key_separator`` Sets the separator for array's keys during its ``.``
899+
flattening
900+
``csv_headers`` Sets the headers for the data ``[]``, inferred from input data's keys
901+
``csv_escape_formulas`` Escapes fields containg formulas by prepending them ``false``
902+
with a ``\t`` character
903+
``as_collection`` Always returns results as a collection, even if only
904+
one line is decoded.
905+
``no_headers`` Disables header in the encoded CSV ``false``
906+
``output_utf8_bom`` Outputs special `UTF-8 BOM`_ along with encoded data ``false``
907+
======================= ==================================================== ==========================
908+
881909
The ``XmlEncoder``
882910
~~~~~~~~~~~~~~~~~~
883911

@@ -945,23 +973,18 @@ which defines the configuration options for the XmlEncoder an associative array:
945973

946974
These are the options available:
947975

948-
``xml_format_output``
949-
If set to true, formats the generated XML with line breaks and indentation.
950-
951-
``xml_version``
952-
Sets the XML version attribute (default: ``1.1``).
953-
954-
``xml_encoding``
955-
Sets the XML encoding attribute (default: ``utf-8``).
956-
957-
``xml_standalone``
958-
Adds standalone attribute in the generated XML (default: ``true``).
959-
960-
``xml_root_node_name``
961-
Sets the root node name (default: ``response``).
962-
963-
``remove_empty_tags``
964-
If set to true, removes all empty tags in the generated XML (default: ``false``).
976+
====================== ==================================================== ==========================
977+
Option Description Default
978+
====================== ==================================================== ==========================
979+
``xml_format_output`` If set to true, formats the generated XML with line
980+
breaks and indentation.
981+
``xml_version`` Sets the XML version attribute ``1.1``
982+
``xml_encoding`` Sets the XML encoding attribute ``utf-8``
983+
``xml_standalone`` Adds standalone attribute in the generated XML ``true``
984+
``xml_root_node_name`` Sets the root node name (default: ``response``).
985+
``remove_empty_tags`` If set to true, removes all empty tags in the ``false``
986+
generated XML
987+
====================== ==================================================== ==========================
965988

966989
The ``YamlEncoder``
967990
~~~~~~~~~~~~~~~~~~~
@@ -1274,49 +1297,6 @@ you indicate that you're expecting an array instead of a single object::
12741297
$data = ...; // The serialized data from the previous example
12751298
$persons = $serializer->deserialize($data, 'Acme\Person[]', 'json');
12761299

1277-
1278-
The ``CsvEncoder``
1279-
------------------
1280-
1281-
This encoder transforms arrays into CSV and vice versa.
1282-
1283-
Context
1284-
~~~~~~~
1285-
1286-
The ``encode()`` method defines a third optional parameter called ``context``
1287-
which defines the configuration options for the CsvEncoder an associative array::
1288-
1289-
$csvEncoder->encode($array, 'csv', $context);
1290-
1291-
These are the options available:
1292-
1293-
``csv_delimiter``
1294-
Sets the field delimiter separating values (one character only, default: ``,``).
1295-
1296-
``csv_enclosure``
1297-
Sets the field enclosure (one character only, default: ``"``).
1298-
1299-
``csv_escape_char``
1300-
Sets the escape character (at most one character, default: empty string).
1301-
1302-
``csv_key_separator``
1303-
Sets the separator for array's keys during its flattening (default: ``.``).
1304-
1305-
``csv_headers``
1306-
Sets the headers for the data (default: ``[]``, inferred from input data's keys).
1307-
1308-
``csv_escape_formulas``
1309-
Escapes fields containg formulas by prepending them with a ``\t`` character (default: ``false``).
1310-
1311-
``as_collection``
1312-
Always returns results as a collection, even if only one line is decoded.
1313-
1314-
``no_headers``
1315-
Disables header in the encoded CSV (default: ``false``).
1316-
1317-
``output_utf8_bom``
1318-
Outputs special `UTF-8 BOM`_ along with encoded data (default: ``false``).
1319-
13201300
Handling Constructor Arguments
13211301
------------------------------
13221302

0 commit comments

Comments
 (0)
0