You are here

public function AbstractManagerRegistry::getManagerForClass 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::getManagerForClass()

Gets the object manager associated with a given class.

Parameters

string $class A persistent object class name.:

Return value

\Doctrine\Common\Persistence\ObjectManager|null

Overrides ManagerRegistry::getManagerForClass

File

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

Class

AbstractManagerRegistry
Abstract implementation of the ManagerRegistry contract.

Namespace

Doctrine\Common\Persistence

Code

public function getManagerForClass($class) {

  // Check for namespace alias
  if (strpos($class, ':') !== false) {
    list($namespaceAlias, $simpleClassName) = explode(':', $class, 2);
    $class = $this
      ->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
  }
  $proxyClass = new \ReflectionClass($class);
  if ($proxyClass
    ->implementsInterface($this->proxyInterfaceName)) {
    $class = $proxyClass
      ->getParentClass()
      ->getName();
  }
  foreach ($this->managers as $id) {
    $manager = $this
      ->getService($id);
    if (!$manager
      ->getMetadataFactory()
      ->isTransient($class)) {
      return $manager;
    }
  }
}