Symfony2 - Call to undefined method getDoctrine() when overriding FOSUserBundle's ProfileController

孤街浪徒 提交于 2019-12-13 18:24:08

问题


When I override FOSUserBundle's ProfileController and add these lines:

  $em = $this->getDoctrine()->getManager();
  $resultat = $em->getRepository('PublishDemandsBundle:Demands')->findAll();

I get the following error:

Call to undefined method Register\UserBundle\Controller\ProfileController::getDoctrine() in ProfileController.php.


回答1:


Adding this alias-method to the controller fixed the issue:

public function getDoctrine()
{
    return $this->container->get('doctrine');
}


来源:https://stackoverflow.com/questions/22841440/symfony2-call-to-undefined-method-getdoctrine-when-overriding-fosuserbundle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!