我有这样的代码在控制器没能获得当前登录用户的Symfony2控制器
public function newAction()
{
$em = $this->getDoctrine()->getEntityManager();
$user = $this->container->get('security.context')->getToken()->getUser();
我收到此错误
Fatal error: Call to a member function getUser() on a non-object in /home/xxxxx/Acme/UserBundle/Controller/UserController.php on line 86
请附上你'你的行动 – 2012-08-15 04:56:16