Skip to content

Commit 2d8c79e

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: Add hint about #[CurrentUser] to the argument_value_resolver page Add hint how to debug argument resolver order
2 parents d28f880 + 46b1e49 commit 2d8c79e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

controller/argument_value_resolver.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
282283
is not triggered when the ``Request`` attribute is present (for example, when
283284
passing 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

Comments
 (0)