Skip to content

Added docs for castToArray() helper #7580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ inside the current node. According to the prototype definition in the example
above, it is possible to have multiple connection arrays (containing a ``driver``,
``host``, etc.).

.. versionadded:: 3.3
The ``castToArray()`` helper was added in Symfony 3.3.

Sometimes, to improve the user experience of your application or bundle, you may
allow to use a simple string or numeric value where an array value is required.
Use the ``castToArray()`` helper to turn those variables into arrays::

->arrayNode('hosts')
->beforeNormalization()->castToArray()->end()
// ...
->end()

Array Node Options
~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -750,8 +762,7 @@ A validation rule also requires a "then" part:
- ``thenUnset()``

Usually, "then" is a closure. Its return value will be used as a new value
for the node, instead
of the node's original value.
for the node, instead of the node's original value.

Processing Configuration Values
-------------------------------
Expand Down