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.
994994-----------------------------
995995
996996After 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::
1001999
10021000 public function indexAction()
10031001 {
10041002 $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
10051003
10061004 $user = $this->getUser();
1007- // or you can also type-hint a method argument with UserInterface: e.g. "UserInterface $user"
10081005 }
10091006
10101007.. tip ::
10111008
10121009 The user will be an object and the class of that object will depend on
10131010 your :ref: `user provider <security-user-providers >`.
10141011
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-
10191012Now you can call whatever methods are on *your * User object. For example,
10201013if your User object has a ``getFirstName() `` method, you could use that::
10211014
You can’t perform that action at this time.
0 commit comments