@@ -720,13 +720,16 @@ In same way, parent options can access to the nested options as normal arrays::
720
720
Prototype Options
721
721
~~~~~~~~~~~~~~~~~
722
722
723
+ .. versionadded :: 5.3
724
+
725
+ Prototype options were introduced in Symfony 5.3.
726
+
723
727
There are situations where you will have to resolve and validate a set of
724
728
options that may repeat many times within another option. Let's imagine a
725
729
``connections `` option that will accept an array of database connections
726
730
with ``host ``, ``database ``, ``user `` and ``password `` each.
727
731
728
- To achieve it, you can establish the nested definition of this ``connections ``
729
- option as prototype::
732
+ The best way to implement this is to define the ``connections `` option as prototype::
730
733
731
734
$resolver->setDefault('connections', function (OptionsResolver $connResolver) {
732
735
$connResolver
@@ -736,7 +739,7 @@ option as prototype::
736
739
});
737
740
738
741
According to the prototype definition in the example above, it is possible
739
- to have multiple connection arrays like following::
742
+ to have multiple connection arrays like the following::
740
743
741
744
$resolver->resolve([
742
745
'connections' => [
@@ -755,16 +758,13 @@ to have multiple connection arrays like following::
755
758
]);
756
759
757
760
The array keys (``default ``, ``test ``, etc.) of this prototype option are
758
- validation-free and can be any valid key you want to differentiate the connections.
761
+ validation-free and can be any arbitrary value that helps differentiate the
762
+ connections.
759
763
760
764
.. note ::
761
765
762
766
A prototype option can only be defined inside a nested option and
763
- during its resolution it will expect an array of array.
764
-
765
- .. versionadded :: 5.3
766
-
767
- The ``setPrototype() `` method was introduced in Symfony 5.3.
767
+ during its resolution it will expect an array of arrays.
768
768
769
769
Deprecating the Option
770
770
~~~~~~~~~~~~~~~~~~~~~~
0 commit comments