Created
June 3, 2013 21:34
-
-
Save davedevelopment/5701627 to your computer and use it in GitHub Desktop.
My doctrine manager registry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Childcare\Common; | |
use Doctrine\Common\Persistence\AbstractManagerRegistry; | |
use Doctrine\ORM\ORMException; | |
use Pimple; | |
class DoctrineManagerRegistry extends AbstractManagerRegistry | |
{ | |
protected $container; | |
protected function getService($name) | |
{ | |
return $this->container[$name]; | |
} | |
protected function resetService($name) | |
{ | |
$this->container[$name] = null; | |
} | |
public function setContainer(Pimple $container = null) | |
{ | |
$this->container = $container; | |
} | |
public function getAliasNamespace($alias) | |
{ | |
foreach (array_keys($this->getManagers()) as $name) { | |
try { | |
return $this->getManager($name)->getConfiguration()->getEntityNamespace($alias); | |
} catch (ORMException $e) { | |
} | |
} | |
throw ORMException::unknownEntityNamespace($alias); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment