resetEntityManager() public method

This method is useful when an entity manager has been closed because of a rollbacked transaction AND when you think that it makes sense to get a new one to replace the closed one. Be warned that you will get a brand new entity manager as the existing one is not useable anymore. This means that any other object with a dependency on this entity manager will hold an obsolete reference. You can inject the registry instead to avoid this problem.
public resetEntityManager ( string $name = null ) : EntityManager
$name string The entity manager name (null for the default one)
return EntityManager
Esempio n. 1
0
 public function testResetUnknownEntityManager()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $registry = new Registry($container, array(), array(), 'default', 'default');
     $this->setExpectedException('InvalidArgumentException', 'Doctrine EntityManager named "default" does not exist.');
     $registry->resetEntityManager('default');
 }