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

Appearance settings

[OptionsResolver] Documenting nested options feature #9995

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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Minor tweaks
  • Loading branch information
yceruto committed Dec 10, 2018
commit 5abcf6a25db9d04d7ba281d99c458bc5a870b8b1
10 changes: 5 additions & 5 deletions 10 components/options_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ Nested Option
.. versionadded:: 4.2
This feature was introduced in Symfony 4.2.

Suppose you want an option named ``spool`` which has two sub-options ``type``
Suppose you have an option named ``spool`` which has two sub-options ``type``
and ``path``. Instead of defining it as a simple array of values, you can pass
a closure as the default value of the ``spool`` option with a :class:`Symfony\\Component\\OptionsResolver\\OptionsResolver`
argument. Based on this instance, you can define the options under ``spool`` and its desired default
Expand Down Expand Up @@ -676,11 +676,11 @@ value::
),
));

It allows you to create a nested options system with required options, validation (type, value),
normalization and more.
Also you can define required options, validation (type, value) and normalization of these
nested options.

If the default value of a child option depend on another option defined in parent level,
adds a second ``Options`` argument to the closure::
adds a second ``Options`` argument to the closure for access to them::

class Mailer
{
Expand All @@ -703,7 +703,7 @@ adds a second ``Options`` argument to the closure::
The arguments of the closure must be type hinted as ``OptionsResolver`` and ``Options`` respectively.
Otherwise, the closure itself is considered as the default value of the option.

In same way, parent options can access the child option as follows::
In same way, parent options can access to the child option as normal array::

class Mailer
{
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.