Skip to content

Added docs about ArgumentValueResolvers #6438

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
Prev Previous commit
Next Next commit
Fixed the list indents
  • Loading branch information
Iltar van der Berg committed Apr 29, 2016
commit 1a19d2e6e738bcbb993c29a0fb5fea47cca7f550
18 changes: 9 additions & 9 deletions cookbook/controller/argument_value_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ Functionality Shipped With The HttpKernel

Symfony ships with four value resolvers in the HttpKernel:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] in the HttpKernel component

* The :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolver\\ArgumentFromAttributeResolver`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an empty line (and remove the indentation for lists here as well)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, use a definition list here:

:class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolver\\ArgumentFromAttributeResolver`
    Attempts to find a request attribute that matches the name of the argument.

:class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolver\\RequestValueResolver`
    Injects the current `Request` if an argument typehinted for `Request` or sub-class.

[...]

attempts to find a request attribute that matches the name of the argument.
attempts to find a request attribute that matches the name of the argument.

* The :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolver\\RequestValueResolver`
injects the current ``Request`` if type-hinted with ``Request``, or a sub-class thereof.
injects the current ``Request`` if type-hinted with ``Request``, or a sub-class thereof.

* The :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolver\\DefaultValueResolver`
will set the default value of the argument if present and the argument is optional.
will set the default value of the argument if present and the argument is optional.

* The :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolver\\VariadicValueResolver`
verifies in the request if your data is an array and will add all of them to the argument list.
When the action is called, the last (variadic) argument will contain all the values of this array.
verifies in the request if your data is an array and will add all of them to the argument list.
When the action is called, the last (variadic) argument will contain all the values of this array.

.. note::

Expand Down Expand Up @@ -64,16 +64,16 @@ This interface specifies that you have to implement two methods::
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the PHP code of the interface.


* The ``supports()`` method is used to check whether the resolver supports the given argument. It will
only continue if it returns ``true``.
only continue if it returns ``true``.

* The ``resolve()`` method will be used to resolve the actual value just acknowledged by
``supports()``. Once a value is resolved you can ``yield`` the value to the ``ArgumentResolver``.
``supports()``. Once a value is resolved you can ``yield`` the value to the ``ArgumentResolver``.

* The ``Request`` object is the current ``Request`` which would also be injected into your
action in the forementioned functionality.
action in the forementioned functionality.

* The :class:``Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata`` represents
information retrieved from the method signature for the current argument it's trying to resolve.
information retrieved from the method signature for the current argument it's trying to resolve.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be one list as it contains 2 different scopes (method description vs argument descriptions). What about:

``supports()``
    This method is used to check whether the value resolver supports the
    given argument. `resolve()` will only be executed when this returns ``true``.
``resolve()``
    This method will resolve the actual value for the argument. Once the value
    is resolved, you should ``yield`` the value to the ``ArgumentResolver``.

Both methods get the ``Request`` object, which is the current request, and a
:class:`Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata`.
This object contains all informations retrieved from the method signature for the
current argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestion looks a lot cleaner 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can tell, only the classname will be shown. I've changed it to "and an ArgumentMetadata"


.. note::

Expand Down