I am new to Symfony. I have created a custom command which sole purpose is to wipe demo data from the system, but I do not know how to do this.
In the controller I would do:
$nodes = $this->getDoctrine()
->getRepository('MyFreelancerPortfolioBundle:TreeNode')
->findAll();
$em = $this->getDoctrine()->getManager();
foreach($nodes as $node)
{
$em->remove($node);
}
$em->flush();
Doing this from the execute() function in the command I get:
Call to undefined method ..... ::getDoctrine();
How would I do this from the execute() function? Also, if there is an easier way to wipe the data other than to loop through them and remove them, feel free to mention it.