Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Fix composer.json and autoloading issue
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Mar 5, 2012
1 parent 7871f68 commit 339ecbc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
18 changes: 15 additions & 3 deletions DoctrineCouchDBBundle.php
Expand Up @@ -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;
Expand All @@ -23,6 +24,11 @@

class DoctrineCouchDBBundle extends Bundle
{
/**
* @var Closure
*/
private $autoloader;

public function build(ContainerBuilder $container)
{
parent::build($container);
Expand All @@ -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';
Expand Down Expand Up @@ -82,7 +88,13 @@ class_exists('Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver');

require $file;
}
});
};
spl_autoload_register($this->autoloader);
}
}
}

public function shutdown()
{
spl_autoload_unregiter($this->autoloader);
}
}
5 changes: 4 additions & 1 deletion composer.json
Expand Up @@ -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": "" }
},
Expand Down

0 comments on commit 339ecbc

Please sign in to comment.