8000 Feedback from PR · linaori/symfony-docs@dd225e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit dd225e8

Browse files
author
Iltar van der Berg
committed
Feedback from PR
1 parent 8d30575 commit dd225e8

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

cookbook/controller/argument_value_resolver.rst

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ this functionality.
1717
Functionality Shipped With The HttpKernel
1818
-----------------------------------------
1919

20-
Symfony ships with four value resolvers in the HttpKernel:
20+
Symfony ships with four value resolvers in the HttpKernel component:
2121

2222
:class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolver\\ArgumentFromAttributeResolver`
2323
Attempts to find a request attribute that matches the name of the argument.
@@ -62,13 +62,7 @@ object from the security system. Given you write the following action::
6262

6363
Somehow you will have to get the ``User`` object and inject it into the controller.
6464
This can be done by implementing the :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolverInterface`.
65-
This interface specifies that you have to implement two methods::
66-
67-
interface ArgumentValueResolverInterface
68-
{
69-
public function supports(Request $request, ArgumentMetadata $argument);
70-
public function resolve(Request $request, ArgumentMetadata $argument);
71-
}
65+
This interface specifies that you have to implement two methods:
7266

7367
``supports()``
7468
This method is used to check whether the value resolver supports the
@@ -82,15 +76,6 @@ Both methods get the ``Request`` object, which is the current request, and an
8276
instance. This object contains all information retrieved from the method signature
8377
for the current argument.
8478

85-
.. note::
86-
87-
The ``ArgumentMetadata`` is a simple data container created by the
88-
:class:`Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadataFactory`.
89-
This factory will work on every supported PHP version but might give
90-
different results. E.g. the ``isVariadic()`` will never return true on
91-
PHP 5.5 and only on PHP 7.0 and higher it will give you basic types when
92-
calling ``getType()``.
93-
9479
Now that you know what to do, you can implement this interface. To get the
9580
current ``User``, you need the current security token. This token can be
9681
retrieved from the token storage::
@@ -134,15 +119,15 @@ retrieved from the token storage::
134119
In order to get the actual ``User`` object in your argument, the given value
135120
must fulfill the following requirements:
136121

137-
* An argument must be typehinted as ``User`` in your action method signature;
122+
* An argument must be type-hinted as ``User`` in your action method signature;
138123
* A security token must be present;
139124
* The value must be an instance of the ``User``.
140125

141126
When all those requirements are met and true is returned, the ``ArgumentResolver``
142127
calls ``resolve()`` with the same values as it called ``supports()``.
143128

144129
That's it! Now all you have to do is add the configuration for the service
145-
container. This can be done by tagging the service with ``kernel.argument_resolver``
130+
container. This can be done by tagging the service with ``controller.argument_resolver``
146131
and adding a priority.
147132

148133
.. note::

0 commit comments

Comments
 (0)
0