@@ -17,7 +17,7 @@ this functionality.
17
17
Functionality Shipped With The HttpKernel
18
18
-----------------------------------------
19
19
20
- Symfony ships with four value resolvers in the HttpKernel:
20
+ Symfony ships with four value resolvers in the HttpKernel component :
21
21
22
22
:class: `Symfony\\ Component\\ HttpKernel\\ Controller\\ ArgumentValueResolver\\ ArgumentFromAttributeResolver `
23
23
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::
62
62
63
63
Somehow you will have to get the ``User `` object and inject it into the controller.
64
64
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:
72
66
73
67
``supports() ``
74
68
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
82
76
instance. This object contains all information retrieved from the method signature
83
77
for the current argument.
84
78
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
-
94
79
Now that you know what to do, you can implement this interface. To get the
95
80
current ``User ``, you need the current security token. This token can be
96
81
retrieved from the token storage::
@@ -134,15 +119,15 @@ retrieved from the token storage::
134
119
In order to get the actual ``User `` object in your argument, the given value
135
120
must fulfill the following requirements:
136
121
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;
138
123
* A security token must be present;
139
124
* The value must be an instance of the ``User ``.
140
125
141
126
When all those requirements are met and true is returned, the ``ArgumentResolver ``
142
127
calls ``resolve() `` with the same values as it called ``supports() ``.
143
128
144
129
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 ``
146
131
and adding a priority.
147
132
148
133
.. note ::
0 commit comments