You are here

public function AbstractManagerRegistry::resetManager in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php \Doctrine\Common\Persistence\AbstractManagerRegistry::resetManager()

Resets a named object manager.

This method is useful when an object 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 object manager as the existing one is not useable anymore. This means that any other object with a dependency on this object manager will hold an obsolete reference. You can inject the registry instead to avoid this problem.

Parameters

string|null $name The object manager name (null for the default one).:

Return value

\Doctrine\Common\Persistence\ObjectManager

Overrides ManagerRegistry::resetManager

File

vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php, line 243

Class

AbstractManagerRegistry
Abstract implementation of the ManagerRegistry contract.

Namespace

Doctrine\Common\Persistence

Code

public function resetManager($name = null) {
  if (null === $name) {
    $name = $this->defaultManager;
  }
  if (!isset($this->managers[$name])) {
    throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name));
  }

  // force the creation of a new document manager
  // if the current one is closed
  $this
    ->resetService($this->managers[$name]);
}