Skip to content

Instantly share code, notes, and snippets.

@jmontoyaa
Forked from umpirsky/ManagerRegistry.php
Last active December 10, 2015 00:49
Show Gist options
  • Save jmontoyaa/4353774 to your computer and use it in GitHub Desktop.
Save jmontoyaa/4353774 to your computer and use it in GitHub Desktop.
<?php
$app['form.extensions'] = $app->share($app->extend('form.extensions', function ($extensions, $app) {
$managerRegistry = new ManagerRegistry(null, array(), array('doctrine_orm.em'), null, null, '\Doctrine\ORM\Proxy\Proxy');
$managerRegistry->setContainer($app);
$extensions[] = new DoctrineOrmExtension($managerRegistry);
return $extensions;
}));
<?php
namespace Umpirsky\Doctrine\Common\Persistance;
use Doctrine\Common\Persistence\AbstractManagerRegistry;
use Silex\Application;
/**
* References Doctrine connections and entity/document managers.
*
* @author Саша Стаменковић <umpirsky@gmail.com>
*/
class ManagerRegistry extends AbstractManagerRegistry
{
/**
* @var Application
*/
protected $container;
protected function getService($name)
{
return $this->container[$name];
}
protected function resetService($name)
{
unset($this->container[$name]);
}
public function getAliasNamespace($alias)
{
throw new \BadMethodCallException('Namespace aliases not supported.');
}
public function setContainer(Application $container)
{
$this->container = $container;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment