src/ResetableEntityManager.php
public function clear($entityName = null)
    {
        try{
            return $this->entityManager->clear($entityName);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }
public function clear($entityName = null)
    {
        try{
            return $this->entityManager->clear($entityName);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }
Clears the EntityManager. All entities that are currently managed
by this EntityManager become detached.

@param string|null $entityName if given, only entities of this type will get detached

@return void