-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Changes from 1 commit
7fc9fe8
7ddf5d6
1a19d2e
f491199
a07fcc3
2e41c07
7cdc96b
7d00d8c
f9cbe71
4c6ed2a
9784406
e3d1b48
55a87b5
8d30575
dd225e8
ca014a6
14d77e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,17 +18,17 @@ Functionality Shipped With The HttpKernel | |
|
||
Symfony ships with four value resolvers in the HttpKernel: | ||
* The :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolver\\ArgumentFromAttributeResolver` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:: | ||
|
||
|
@@ -64,16 +64,16 @@ This interface specifies that you have to implement two methods:: | |
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your suggestion looks a lot cleaner 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] in the HttpKernel component