Skip to content

Commit 6261a05

Browse files
committed
feature #7580 Added docs for castToArray() helper (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Added docs for castToArray() helper This documents symfony/symfony#21893 Commits ------- 4b1f800 Added docs for castToArray() helper
2 parents 95d8d36 + 4b1f800 commit 6261a05

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

components/config/definition.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ inside the current node. According to the prototype definition in the example
190190
above, it is possible to have multiple connection arrays (containing a ``driver``,
191191
``host``, etc.).
192192

193+
.. versionadded:: 3.3
194+
The ``castToArray()`` helper was added in Symfony 3.3.
195+
196+
Sometimes, to improve the user experience of your application or bundle, you may
197+
allow to use a simple string or numeric value where an array value is required.
198+
Use the ``castToArray()`` helper to turn those variables into arrays::
199+
200+
->arrayNode('hosts')
201+
->beforeNormalization()->castToArray()->end()
202+
// ...
203+
->end()
204+
193205
Array Node Options
194206
~~~~~~~~~~~~~~~~~~
195207

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

752764
Usually, "then" is a closure. Its return value will be used as a new value
753-
for the node, instead
754-
of the node's original value.
765+
for the node, instead of the node's original value.
755766

756767
Processing Configuration Values
757768
-------------------------------

0 commit comments

Comments
 (0)