Skip to content

Commit 46b1e49

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

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

controller/argument_value_resolver.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ In addition, some components and official bundles provide other value resolvers:
4949

5050
:class:`Symfony\\Component\\Security\\Http\\Controller\\UserValueResolver`
5151
Injects the object that represents the current logged in user if type-hinted
52-
with ``UserInterface``. Default value can be set to ``null`` in case
53-
the controller can be accessed by anonymous users. It requires installing
54-
the :doc:`SecurityBundle </security>`.
52+
with ``UserInterface``. You can also type-hint your own ``User`` class but you
53+
must then add the ``#[CurrentUser]`` attribute to the argument. Default value
54+
can be set to ``null`` in case the controller can be accessed by anonymous
55+
users. It requires installing the :doc:`SecurityBundle </security>`.
5556

5657
Adding a Custom Value Resolver
5758
------------------------------
@@ -242,6 +243,13 @@ Otherwise, set a priority lower than ``100`` to make sure the argument resolver
242243
is not triggered when the ``Request`` attribute is present (for example, when
243244
passing the user along sub-requests).
244245

246+
To ensure your resolvers are added in the right position you can run the following
247+
command to see which argument resolvers are present and in which order they run.
248+
249+
.. code-block:: terminal
250+
251+
$ php bin/console debug:container debug.argument_resolver.inner --show-arguments
252+
245253
.. tip::
246254

247255
As you can see in the ``UserValueResolver::supports()`` method, the user

0 commit comments

Comments
 (0)