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
Next Next commit
fix typos
  • Loading branch information
yceruto committed Dec 10, 2018
commit 4412e91c8b27bd7cbf32b2bf3fb9f51f4bee0f9a
12 changes: 6 additions & 6 deletions 12 components/options_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -634,15 +634,15 @@ let you find out which options are defined::
}
}

Nested option
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``
and ``path``. Instead of define it as a simple array of values, you can pass
a closure as the default value of the ``spool`` option with an :class:`Symfony\\Component\\OptionsResolver\\OptionsResolver`
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
value::

Expand Down Expand Up @@ -706,7 +706,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 to the child option as follows::
In same way, parent options can access the child option as follows::

// ...
class Mailer
Expand All @@ -730,8 +730,8 @@ In same way, parent options can access to the child option as follows::

.. note::

The fact that an option is defined as nested, means that you must to pass
an array of values to resolve it on runtime.
The fact that an option is defined as nested means that you must pass
an array of values to resolve it at runtime.

Deprecating the Option
~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.