Skip to content
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

[#6438] some tweaks to the argument value resolver #6651

Merged
merged 1 commit into from
Jun 20, 2016
Merged
Changes from all commits
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
14 changes: 7 additions & 7 deletions cookbook/controller/argument_value_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Symfony ships with four value resolvers in the HttpKernel component:
Adding a Custom Value Resolver
------------------------------

Adding a new value resolver requires creatign one class and one service
Adding a new value resolver requires creating one class and one service
definition. In the next example, you'll create a value resolver to inject the
``User`` object from the security system. Given you write the following
controller::
Expand Down Expand Up @@ -189,13 +189,13 @@ subrequests.

.. tip::

As you see in the ``UserValueResolver::supports()`` method, the user may
not be available (e.g. when the controller is not behind a firewall). In
these cases, the resolver will not be executed. If no argument value is
resolved, an exception will be throwed.
As you can see in the ``UserValueResolver::supports()`` method, the user
may not be available (e.g. when the controller is not behind a firewall).
In these cases, the resolver will not be executed. If no argument value
is resolved, an exception will be thrown.

To prevent this, you can add a default value in the controller (e.g. ``User
$user = null``). The ``DefaultValueResolver`` is executed as last resolver
and will use the default value if no value is resolved already.
$user = null``). The ``DefaultValueResolver`` is executed as the last
resolver and will use the default value if no value was already resolved.

.. _`yield`: http://php.net/manual/en/language.generators.syntax.php