public function clearEntityManager($managerName = null)
    {
        if (null === $this->doctrine) {
            throw new \Exception('Doctrine is required');
        }

        if (null === $managerName) {
            $managerName = $this->doctrine->getDefaultConnectionName();
        }
        if (!array_key_exists($managerName, $this->snapshots)) {
            throw new \Exception('The snapshot was not done');
        }
        $snapshot = $this->snapshots[$managerName];

        $em = $this->doctrine->getManager($managerName);
        $identityMap = $em->getUnitOfWork()->getIdentityMap();
        foreach ($identityMap as $class => $objects) {
            foreach ($objects as $id => $object) {
                if (!array_key_exists($class, $snapshot) || !array_key_exists($id, $snapshot[$class])) {
                    $em->detach($object);
                }
            }
        }
    }
public function clearEntityManager($managerName = null)
    {
        if (null === $this->doctrine) {
            throw new \Exception('Doctrine is required');
        }

        if (null === $managerName) {
            $managerName = $this->doctrine->getDefaultConnectionName();
        }
        if (!array_key_exists($managerName, $this->snapshots)) {
            throw new \Exception('The snapshot was not done');
        }
        $snapshot = $this->snapshots[$managerName];

        $em = $this->doctrine->getManager($managerName);
        $identityMap = $em->getUnitOfWork()->getIdentityMap();
        foreach ($identityMap as $class => $objects) {
            foreach ($objects as $id => $object) {
                if (!array_key_exists($class, $snapshot) || !array_key_exists($id, $snapshot[$class])) {
                    $em->detach($object);
                }
            }
        }
    }
public function clearEntityManager ( $ managerName = null ) { if ( null === $ this -> doctrine ) { throw new \ Exception ( 'Doctrine is required' ) ; } if ( null === $ managerName ) { $ managerName = $ this -> doctrine -> getDefaultConnectionName ( ) ; } if ( ! array_key_exists ( $ managerName , $ this -> snapshots ) ) { throw new \ Exception ( 'The snapshot was not done' ) ; } $ snapshot = $ this -> snapshots [ $ managerName ] ; $ em = $ this -> doctrine -> getManager ( $ managerName ) ; $ identityMap = $ em -> getUnitOfWork ( ) -> getIdentityMap ( ) ; foreach ( $ identityMap as $ class => $ objects ) { foreach ( $ objects as $ id => $ object ) { if ( ! array_key_exists ( $ class , $ snapshot ) || ! array_key_exists ( $ id , $ snapshot [ $ class ] ) ) { $ em -> detach ( $ object ) ; } } } }
Detach all objects in EntityManager persisted since snapshot
@param string|null $managerName
Detach all objects in EntityManager persisted since snapshot