Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb600aa0

Browse files
committed
List CSV encoder's context options
1 parentb4c79d7 commitb600aa0

File tree

1 file changed

+47
-7
lines changed

1 file changed

+47
-7
lines changed

‎components/serializer.rst‎

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -810,13 +810,6 @@ The ``CsvEncoder``
810810

811811
The ``CsvEncoder`` encodes to and decodes from CSV.
812812

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-
820813
The ``XmlEncoder``
821814
~~~~~~~~~~~~~~~~~~
822815

@@ -1254,6 +1247,52 @@ These are the options available:
12541247
``remove_empty_tags``
12551248
If set to true, removes all empty tags in the generated XML.
12561249

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+
12571296
Handling Constructor Arguments
12581297
------------------------------
12591298

@@ -1506,6 +1545,7 @@ Learn more
15061545
.. _YAML:http://yaml.org/
15071546
.. _CSV:https://tools.ietf.org/html/rfc4180
15081547
.. _`RFC 7807`:https://tools.ietf.org/html/rfc7807
1548+
.. _`UTF-8 BOM`:https://en.wikipedia.org/wiki/Byte_order_mark
15091549
.. _`Value Objects`:https://en.wikipedia.org/wiki/Value_object
15101550
.. _`API Platform`:https://api-platform.com
15111551
.. _`list of PHP timezones`:https://www.php.net/manual/en/timezones.php

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp