@@ -149,7 +149,7 @@ and adding a priority.
149
149
150
150
While adding a priority is optional, it's recommended to add one to
151
151
make sure the expected value is injected. The ``ArgumentFromAttributeResolver ``
152
- has a priority of 100. As this one is responsible for fetching attributes
152
+ has a priority of 100. As this one is responsible for fetching attributes
153
153
from the ``Request ``, it's also recommended to trigger your custom value
154
154
resolver with a lower priority. This makes sure the argument resolvers
155
155
are not triggered in (e.g.) subrequests if you pass your user along:
@@ -197,8 +197,6 @@ and adding a priority.
197
197
$definition->addTag('controller.argument_value_resolver', array('priority' => 50));
198
198
$container->setDefinition('app.value_resolver.user', $definition);
199
199
200
- .. _`yield` : http://php.net/manual/en/language.generators.syntax.php
201
-
202
200
Creating an Optional User Resolver
203
201
----------------------------------
204
202
@@ -209,13 +207,17 @@ method signature to `UserInterface $user = null`.
209
207
210
208
When you take the ``UserValueResolver `` from the previous example, you can
211
209
see there is no logic in case of failure to comply to the requirements. Default
212
- values in are defined in the signature and are available in the ``ArgumentMetadata ``.
210
+ values are defined in the signature and are available in the ``ArgumentMetadata ``.
213
211
When a default value is available and there are no resolvers that support
214
212
the given value, the ``DefaultValueResolver `` is triggered. This Resolver
215
213
takes the default value of your argument and yields it to the argument list::
216
214
217
215
namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver;
218
216
217
+ use Symfony\Component\HttpFoundation\Request;
218
+ use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
219
+ use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
220
+
219
221
final class DefaultValueResolver implements ArgumentValueResolverInterface
220
222
{
221
223
public function supports(Request $request, ArgumentMetadata $argument)
@@ -228,3 +230,5 @@ takes the default value of your argument and yields it to the argument list::
228
230
yield $argument->getDefaultValue();
229
231
}
230
232
}
233
+
234
+ .. _`yield` : http://php.net/manual/en/language.generators.syntax.php
0 commit comments