File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change @@ -994,28 +994,21 @@ shown above.
994
994
-----------------------------
995
995
996
996
After authentication, the ``User `` object of the current user can be accessed
997
- via the ``security.token_storage `` service. From inside a controller, this will
998
- look like::
999
-
1000
- use Symfony\Component\Security\Core\User\UserInterface;
997
+ via the ``getUser() `` shortcut (which uses the ``security.token_storage ``
998
+ service). From inside a controller, this will look like::
1001
999
1002
1000
public function indexAction()
1003
1001
{
1004
1002
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
1005
1003
1006
1004
$user = $this->getUser();
1007
- // or you can also type-hint a method argument with UserInterface: e.g. "UserInterface $user"
1008
1005
}
1009
1006
1010
1007
.. tip ::
1011
1008
1012
1009
The user will be an object and the class of that object will depend on
1013
1010
your :ref: `user provider <security-user-providers >`.
1014
1011
1015
- .. versionadded :: 3.2
1016
- The ability to get the user by type-hinting an argument with UserInterface
1017
- was introduced in Symfony 3.2.
1018
-
1019
1012
Now you can call whatever methods are on *your * User object. For example,
1020
1013
if your User object has a ``getFirstName() `` method, you could use that::
1021
1014
You can’t perform that action at this time.
0 commit comments