Skip to content

Commit ab03594

Browse files
pathmissingweaverryan
authored andcommitted
Implement proposed changes
1 parent 09c6616 commit ab03594

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

security.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,13 +1001,10 @@ look like::
10011001

10021002
public function indexAction()
10031003
{
1004-
if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
1005-
throw $this->createAccessDeniedException();
1006-
}
1004+
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
10071005

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"
10111008
}
10121009

10131010
.. tip::
@@ -1016,10 +1013,8 @@ look like::
10161013
your :ref:`user provider <security-user-providers>`.
10171014

10181015
.. 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.
10231018

10241019
Now you can call whatever methods are on *your* User object. For example,
10251020
if your User object has a ``getFirstName()`` method, you could use that::

0 commit comments

Comments
 (0)