Skip to content

Instantly share code, notes, and snippets.

@davedevelopment
Created June 3, 2013 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davedevelopment/5701627 to your computer and use it in GitHub Desktop.
Save davedevelopment/5701627 to your computer and use it in GitHub Desktop.
My doctrine manager registry
<?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