@@ -85,10 +85,11 @@ In addition, some components and official bundles provide other value resolvers:
8585
8686:class: `Symfony\\ Component\\ Security\\ Http\\ Controller\\ UserValueResolver `
8787 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+
9293 If the argument is not nullable and there is no logged in user or the logged in
9394 user has a user class not matching the type-hinted class, an ``AccessDeniedException ``
9495 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
282283is not triggered when the ``Request `` attribute is present (for example, when
283284passing the user along sub-requests).
284285
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+
285293 .. tip ::
286294
287295 As you can see in the ``UserValueResolver::supports() `` method, the user
0 commit comments