public function AbstractManagerRegistry::getManagerForClass in Plug 7
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
- lib/
doctrine/ common/ lib/ Doctrine/ Common/ Persistence/ AbstractManagerRegistry.php, line 189
Class
- AbstractManagerRegistry
- Abstract implementation of the ManagerRegistry contract.
Namespace
Doctrine\Common\PersistenceCode
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;
}
}
}