@@ -823,6 +823,38 @@ The ``CsvEncoder``
823
823
824
824
The ``CsvEncoder `` encodes to and decodes from CSV.
825
825
826
+ The ``CsvEncoder `` Context Options
827
+ ..................................
828
+
829
+ The ``encode() `` method defines a third optional parameter called ``context ``
830
+ which defines the configuration options for the CsvEncoder an associative array::
831
+
832
+ $csvEncoder->encode($array, 'csv', $context);
833
+
834
+ These are the options available:
835
+
836
+ ======================= ==================================================== ==========================
837
+ Option Description Default
838
+ ======================= ==================================================== ==========================
839
+ ``csv_delimiter `` Sets the field delimiter separating values (one ``, ``
840
+ character only)
841
+ ``csv_enclosure `` Sets the field enclosure (one character only) ``" ``
842
+ ``csv_escape_char `` Sets the escape character (at most one character)
843
+ ``csv_key_separator `` Sets the separator for array's keys during its ``. ``
844
+ flattening
845
+ ``csv_headers `` Sets the headers for the data ``[] ``, inferred from input data's keys
846
+ ``csv_escape_formulas `` Escapes fields containg formulas by prepending them ``false ``
847
+ with a ``\t `` character
848
+ ``as_collection `` Always returns results as a collection, even if only
849
+ one line is decoded.
850
+ ``no_headers `` Disables header in the encoded CSV ``false ``
851
+ ``output_utf8_bom `` Outputs special `UTF-8 BOM `_ along with encoded data ``false ``
852
+ ======================= ==================================================== ==========================
853
+
854
+ .. versionadded :: 4.4
855
+
856
+ The ``output_utf8_bom `` option was introduced in Symfony 4.4.
857
+
826
858
The ``XmlEncoder ``
827
859
~~~~~~~~~~~~~~~~~~
828
860
@@ -891,23 +923,18 @@ which defines the configuration options for the XmlEncoder an associative array:
891
923
892
924
These are the options available:
893
925
894
- ``xml_format_output ``
895
- If set to true, formats the generated XML with line breaks and indentation.
896
-
897
- ``xml_version ``
898
- Sets the XML version attribute (default: ``1.1 ``).
899
-
900
- ``xml_encoding ``
901
- Sets the XML encoding attribute (default: ``utf-8 ``).
902
-
903
- ``xml_standalone ``
904
- Adds standalone attribute in the generated XML (default: ``true ``).
905
-
906
- ``xml_root_node_name ``
907
- Sets the root node name (default: ``response ``).
908
-
909
- ``remove_empty_tags ``
910
- If set to true, removes all empty tags in the generated XML (default: ``false ``).
926
+ ====================== ==================================================== ==========================
927
+ Option Description Default
928
+ ====================== ==================================================== ==========================
929
+ ``xml_format_output `` If set to true, formats the generated XML with line
930
+ breaks and indentation.
931
+ ``xml_version `` Sets the XML version attribute ``1.1 ``
932
+ ``xml_encoding `` Sets the XML encoding attribute ``utf-8 ``
933
+ ``xml_standalone `` Adds standalone attribute in the generated XML ``true ``
934
+ ``xml_root_node_name `` Sets the root node name (default: ``response ``).
935
+ ``remove_empty_tags `` If set to true, removes all empty tags in the ``false ``
936
+ generated XML
937
+ ====================== ==================================================== ==========================
911
938
912
939
The ``YamlEncoder ``
913
940
~~~~~~~~~~~~~~~~~~~
@@ -1232,53 +1259,6 @@ you indicate that you're expecting an array instead of a single object::
1232
1259
$data = ...; // The serialized data from the previous example
1233
1260
$persons = $serializer->deserialize($data, 'Acme\Person[]', 'json');
1234
1261
1235
-
1236
- The ``CsvEncoder ``
1237
- ------------------
1238
-
1239
- This encoder transforms arrays into CSV and vice versa.
1240
-
1241
- Context
1242
- ~~~~~~~
1243
-
1244
- The ``encode() `` method defines a third optional parameter called ``context ``
1245
- which defines the configuration options for the CsvEncoder an associative array::
1246
-
1247
- $csvEncoder->encode($array, 'csv', $context);
1248
-
1249
- These are the options available:
1250
-
1251
- ``csv_delimiter ``
1252
- Sets the field delimiter separating values (one character only, default: ``, ``).
1253
-
1254
- ``csv_enclosure ``
1255
- Sets the field enclosure (one character only, default: ``" ``).
1256
-
1257
- ``csv_escape_char ``
1258
- Sets the escape character (at most one character, default: empty string).
1259
-
1260
- ``csv_key_separator ``
1261
- Sets the separator for array's keys during its flattening (default: ``. ``).
1262
-
1263
- ``csv_headers ``
1264
- Sets the headers for the data (default: ``[] ``, inferred from input data's keys).
1265
-
1266
- ``csv_escape_formulas ``
1267
- Escapes fields containg formulas by prepending them with a ``\t `` character (default: ``false ``).
1268
-
1269
- ``as_collection ``
1270
- Always returns results as a collection, even if only one line is decoded.
1271
-
1272
- ``no_headers ``
1273
- Disables header in the encoded CSV (default: ``false ``).
1274
-
1275
- ``output_utf8_bom ``
1276
- Outputs special `UTF-8 BOM `_ along with encoded data (default: ``false ``).
1277
-
1278
- .. versionadded :: 4.4
1279
-
1280
- The ``output_utf8_bom `` option was introduced in Symfony 4.4.
1281
-
1282
1262
Handling Constructor Arguments
1283
1263
------------------------------
1284
1264
0 commit comments