Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想让用户当前连接到会话。我的意思是,因为我们可以通过这个获得角色:
$this->get('security.context')->isGranted('ROLE_ADMIN')
我们可以得到用户吗?
你可以像这样获取当前用户
$securityContext = $this->get('security.context'); $user = $securityContext->getToken()->getUser();