In my current symfony project i work with doctrine.
in one of my controllers i am creating an object and saving it to the db:
$article = new Article();
$article->setName('article');
$em = $this->getDoctrine()->getManager();
$em->persist($article);
$em->flush();
$data = $this->prepareIndexAction();
$html = $this->container->get('templating')->render(
'index.html.twig',
['data' => $data]
);
return new Response($html);
This object is saved two times to the database.
Anybody knows how to deal with this?
Greetings and thanks!