Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb88894

Browse files
Added info on new controller getUser shortcut
1 parent 26d17e3 commit eb88894

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

book/security.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,16 @@ look like:
11811181
$user = $this->get('security.context')->getToken()->getUser();
11821182
}
11831183
1184+
In a controller this can be shortcut to:
1185+
1186+
.. code-block:: php
1187+
1188+
public function indexAction()
1189+
{
1190+
$user = $this->getUser();
1191+
}
1192+
1193+
11841194
.. note::
11851195

11861196
Anonymous users are technically authenticated, meaning that the ``isAuthenticated()``

0 commit comments

Comments
 (0)