@@ -634,17 +634,18 @@ let you find out which options are defined::
634
634
}
635
635
}
636
636
637
- Nested Option
638
- ~~~~~~~~~~~~~
637
+ Nested Options
638
+ ~~~~~~~~~~~~~~
639
639
640
640
.. versionadded :: 4.2
641
- This feature was introduced in Symfony 4.2.
641
+ The support of nested options was introduced in Symfony 4.2.
642
642
643
643
Suppose you have an option named ``spool `` which has two sub-options ``type ``
644
- and ``path ``. Instead of defining it as a simple array of values, you can pass
645
- a closure as the default value of the ``spool `` option with a :class: `Symfony\\ Component\\ OptionsResolver\\ OptionsResolver `
646
- argument. Based on this instance, you can define the options under ``spool `` and its desired default
647
- value::
644
+ and ``path ``. Instead of defining it as a simple array of values, you can pass a
645
+ closure as the default value of the ``spool `` option with a
646
+ :class: `Symfony\\ Component\\ OptionsResolver\\ OptionsResolver ` argument. Based on
647
+ this instance, you can define the options under ``spool `` and its desired
648
+ default value::
648
649
649
650
class Mailer
650
651
{
@@ -676,11 +677,10 @@ value::
676
677
),
677
678
));
678
679
679
- Also you can define required options, validation (type, value) and normalization of these
680
- nested options.
681
-
682
- If the default value of a child option depend on another option defined in parent level,
683
- adds a second ``Options `` argument to the closure for access to them::
680
+ Nested options also support required options, validation (type, value) and
681
+ normalization of their values. If the default value of a nested option depends
682
+ on another option defined in the parent level, add a second ``Options `` argument
683
+ to the closure to access to them::
684
684
685
685
class Mailer
686
686
{
@@ -700,10 +700,11 @@ adds a second ``Options`` argument to the closure for access to them::
700
700
701
701
.. caution ::
702
702
703
- The arguments of the closure must be type hinted as ``OptionsResolver `` and ``Options `` respectively.
704
- Otherwise, the closure itself is considered as the default value of the option.
703
+ The arguments of the closure must be type hinted as ``OptionsResolver `` and
704
+ ``Options `` respectively. Otherwise, the closure itself is considered as the
705
+ default value of the option.
705
706
706
- In same way, parent options can access to the child option as normal array ::
707
+ In same way, parent options can access to the nested options as normal arrays ::
707
708
708
709
class Mailer
709
710
{
0 commit comments