@@ -85,10 +85,11 @@ In addition, some components and official bundles provide other value resolvers:
85
85
86
86
:class: `Symfony\\ Component\\ Security\\ Http\\ Controller\\ UserValueResolver `
87
87
Injects the object that represents the current logged in user if type-hinted
88
- with ``UserInterface ``. Default value can be set to ``null `` in case
89
- the controller can be accessed by anonymous users. It requires installing
90
- the :doc: `SecurityBundle </security >`.
91
-
88
+ with ``UserInterface ``. You can also type-hint your own ``User `` class but you
89
+ must then add the ``#[CurrentUser] `` attribute to the argument. Default value
90
+ can be set to ``null `` in case the controller can be accessed by anonymous
91
+ users. It requires installing the :doc: `SecurityBundle </security >`.
92
+
92
93
If the argument is not nullable and there is no logged in user or the logged in
93
94
user has a user class not matching the type-hinted class, an ``AccessDeniedException ``
94
95
is thrown by the resolver to prevent access to the controller.
@@ -282,6 +283,13 @@ Otherwise, set a priority lower than ``100`` to make sure the argument resolver
282
283
is not triggered when the ``Request `` attribute is present (for example, when
283
284
passing the user along sub-requests).
284
285
286
+ To ensure your resolvers are added in the right position you can run the following
287
+ command to see which argument resolvers are present and in which order they run.
288
+
289
+ .. code-block :: terminal
290
+
291
+ $ php bin/console debug:container debug.argument_resolver.inner --show-arguments
292
+
285
293
.. tip ::
286
294
287
295
As you can see in the ``UserValueResolver::supports() `` method, the user
0 commit comments