diff --git a/DoctrineCouchDBBundle.php b/DoctrineCouchDBBundle.php index 2d612f5..e7121be 100644 --- a/DoctrineCouchDBBundle.php +++ b/DoctrineCouchDBBundle.php @@ -15,6 +15,7 @@ namespace Doctrine\Bundle\CouchDBBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; +use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\RegisterEventListenersAndSubscribersPass; @@ -23,6 +24,11 @@ class DoctrineCouchDBBundle extends Bundle { + /** + * @var Closure + */ + private $autoloader; + public function build(ContainerBuilder $container) { parent::build($container); @@ -48,7 +54,7 @@ class_exists('Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver'); $dir = $this->container->getParameter('doctrine_couchdb.odm.proxy_dir'); $container = $this->container; - spl_autoload_register(function($class) use ($namespace, $dir, $container) { + $this->autoloader = function($class) use ($namespace, $dir, $container) { if (0 === strpos($class, $namespace)) { $className = substr($class, strlen($namespace) +1); $file = $dir.DIRECTORY_SEPARATOR.$className.'.php'; @@ -82,7 +88,13 @@ class_exists('Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver'); require $file; } - }); + }; + spl_autoload_register($this->autoloader); } } -} \ No newline at end of file + + public function shutdown() + { + spl_autoload_unregiter($this->autoloader); + } +} diff --git a/composer.json b/composer.json index 72b0dde..1210a46 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,12 @@ ], "require": { "php": ">=5.3.2", - "doctrine/couchdb-odm": "*", + "doctrine/couchdb": "*", "symfony/symfony": "2.1.*" }, + "suggest": { + "doctrine/couchdb-odm": "*" + }, "autoload": { "psr-0": { "Doctrine\\Bundle\\DoctrineCouchDBBundle": "" } },