问题
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