@@ -810,13 +810,6 @@ The ``CsvEncoder``
810
810
811
811
The ``CsvEncoder `` encodes to and decodes from CSV.
812
812
813
- You can pass the context key ``as_collection `` in order to have the results
814
- always as a collection.
815
-
816
- .. deprecated :: 4.2
817
-
818
- Relying on the default value ``false `` is deprecated since Symfony 4.2.
819
-
820
813
The ``XmlEncoder ``
821
814
~~~~~~~~~~~~~~~~~~
822
815
@@ -1254,6 +1247,52 @@ These are the options available:
1254
1247
``remove_empty_tags ``
1255
1248
If set to true, removes all empty tags in the generated XML.
1256
1249
1250
+ The ``CsvEncoder ``
1251
+ ------------------
1252
+
1253
+ This encoder transforms arrays into CSV and vice versa.
1254
+
1255
+ Context
1256
+ ~~~~~~~
1257
+
1258
+ The ``encode() `` method defines a third optional parameter called ``context ``
1259
+ which defines the configuration options for the CsvEncoder an associative array::
1260
+
1261
+ $csvEncoder->encode($array, 'csv', $context);
1262
+
1263
+ These are the options available:
1264
+
1265
+ ``csv_delimiter ``
1266
+ Sets the field delimiter separating values (one character only, default: ``, ``).
1267
+
1268
+ ``csv_enclosure ``
1269
+ Sets the field enclosure (one character only, default: ``" ``).
1270
+
1271
+ ``csv_escape_char ``
1272
+ Sets the escape character (at most one character, default: empty string).
1273
+
1274
+ ``csv_key_separator ``
1275
+ Sets the separator for array's keys during its flattening (default: ``. ``).
1276
+
1277
+ ``csv_headers ``
1278
+ Sets the headers for the data (default: ``[] ``, inferred from input data's keys).
1279
+
1280
+ ``csv_escape_formulas ``
1281
+ Escapes fields containg formulas by prepending them with a ``\t `` character (default: ``false ``).
1282
+
1283
+ ``as_collection ``
1284
+ Always returns results as a collection, even if only one line is decoded (default: ``false ``).
1285
+
1286
+ .. deprecated :: 4.2
1287
+
1288
+ Relying on the default value ``false `` is deprecated since Symfony 4.2.
1289
+
1290
+ ``no_headers ``
1291
+ Disables header in the encoded CSV (default: ``false ``).
1292
+
1293
+ ``output_utf8_bom ``
1294
+ Outputs special `UTF-8 BOM `_ along with encoded data (default: ``false ``).
1295
+
1257
1296
Handling Constructor Arguments
1258
1297
------------------------------
1259
1298
@@ -1506,6 +1545,7 @@ Learn more
1506
1545
.. _YAML : http://yaml.org/
1507
1546
.. _CSV : https://tools.ietf.org/html/rfc4180
1508
1547
.. _`RFC 7807` : https://tools.ietf.org/html/rfc7807
1548
+ .. _`UTF-8 BOM` : https://en.wikipedia.org/wiki/Byte_order_mark
1509
1549
.. _`Value Objects` : https://en.wikipedia.org/wiki/Value_object
1510
1550
.. _`API Platform` : https://api-platform.com
1511
1551
.. _`list of PHP timezones` : https://www.php.net/manual/en/timezones.php
0 commit comments