28/05/2015 - DOCTRINE, SYMFONY
Many reasons might cause this error but the solution is simple.
Doctrine\ORM\ORMException exception "The EntityManager is closed".
public function doSoemthing()
{
// ....
$this->em = $this->refreshEntityManager($this->em);
// ....
}
/**
* @param $em EntityManager
*
* @return EntityManager
*/
private function refreshEntityManager(EntityManager $em)
{
if (!$em->isOpen()) {
$em = $em->create($em->getConnection(), $em->getConfiguration());
}
return $em;
}