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

Commit72781cf

Browse files
authored
List CSV encoder's context options
1 parentb4c79d7 commit72781cf

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

‎components/serializer.rst‎

Lines changed: 43 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,48 @@ 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 CSV Encoder
1251+
---------------
1252+
1253+
This encoder transforms arrays into XML 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+
``csv_delimiter``
1262+
Sets the field delimiter separating values (one character only, default: ``,``).
1263+
1264+
``csv_enclosure``
1265+
Sets the field enclosure (one character only, default: ``"``).
1266+
1267+
``csv_escape_char``
1268+
Sets the escape character (at most one character, default: empty string).
1269+
1270+
``csv_key_separator``
1271+
Sets the separator for array's keys during its flattening (default: ``.``).
1272+
1273+
``csv_headers``
1274+
Sets the headers for the data (default: ``[]``, inferred from input data's keys).
1275+
1276+
``csv_escape_formulas``
1277+
Escapes fields containg formulas by prepending them with a ``\t`` character (default: ``false``).
1278+
1279+
``as_collection``
1280+
Always returns results as a collection, even if only one line is decoded (default: ``false``).
1281+
1282+
..deprecated::4.2
1283+
1284+
Relying on the default value ``false`` is deprecated since Symfony 4.2.
1285+
1286+
``no_headers``
1287+
Disables header in the encoded CSV (default: `false`).
1288+
1289+
``output_utf8_bom``
1290+
Outputs special `UTF-8 BOM`_ along with encoded data (default: `false`).
1291+
12571292
Handling Constructor Arguments
12581293
------------------------------
12591294

@@ -1506,6 +1541,7 @@ Learn more
15061541
.. _YAML:http://yaml.org/
15071542
.. _CSV:https://tools.ietf.org/html/rfc4180
15081543
.. _`RFC 7807`:https://tools.ietf.org/html/rfc7807
1544+
.. _`UTF-8 BOM`:https://en.wikipedia.org/wiki/Byte_order_mark
15091545
.. _`Value Objects`:https://en.wikipedia.org/wiki/Value_object
15101546
.. _`API Platform`:https://api-platform.com
15111547
.. _`list of PHP timezones`:https://www.php.net/manual/en/timezones.php

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp