I am very new to Symfony2 and can't seem to wrap my head around this issue. When executing an action, I am receiving this error:
Call to undefined method: getDoctrine()
Controller:
public function createAction() {
$string = new FrontendString();
$string->setStringval("Hayaku!");
$em = $this->getDoctrine()->getManager();
$em->persist($string);
$em->flush();
return new Response('Created string with id '. $string->getId());
}
The Entity file has all its generated getters and setters according to correct annotations. I have no Repository or Model folder. Am I missing something obvious?
Make sure your controller extends Symfony\Bundle\FrameworkBundle\Controller\Controller, read about it in documentation
For convenience, Symfony2 comes with a base Controller class that assists with some of the most common controller tasks and gives your controller class access to any resource it might need. By extending this Controller class, you can take advantage of several helper methods.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments