File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -1001,13 +1001,10 @@ look like::
1001
1001
1002
1002
public function indexAction()
1003
1003
{
1004
- if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
1005
- throw $this->createAccessDeniedException();
1006
- }
1004
+ $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
1007
1005
1008
- // This is the recommended way but type-hinting the
1009
- // UserInterface as a method argument also works
1010
- $user = $this->get('security.token_storage')->getToken()->getUser();
1006
+ $user = $this->getUser();
1007
+ // or you can also type-hint a method argument with UserInterface: e.g. "UserInterface $user"
1011
1008
}
1012
1009
1013
1010
.. tip ::
@@ -1016,10 +1013,8 @@ look like::
1016
1013
your :ref: `user provider <security-user-providers >`.
1017
1014
1018
1015
.. versionadded :: 3.2
1019
- The functionality to get the user via the method signature was introduced in
1020
- Symfony 3.2. You can still retrieve it by calling ``$this->getUser() `` if you
1021
- extend the :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ Controller `
1022
- class.
1016
+ The ability to get the user by type-hinting an argument with UserInterface
1017
+ was introduced in Symfony 3.2.
1023
1018
1024
1019
Now you can call whatever methods are on *your * User object. For example,
1025
1020
if your User object has a ``getFirstName() `` method, you could use that::
You can’t perform that action at this time.
0 commit comments