The EntityManager is closed
Solution 1:
My solution.
Before doing anything check:
if (!$this->entityManager->isOpen()) {
$this->entityManager = $this->entityManager->create(
$this->entityManager->getConnection(),
$this->entityManager->getConfiguration()
);
}
All entities will be saved. But it is handy for particular class or some cases. If you have some services with injected entitymanager, it still be closed.
Solution 2:
Symfony 2.0:
$em = $this->getDoctrine()->resetEntityManager();
Symfony 2.1+:
$em = $this->getDoctrine()->resetManager();