Skip to content

Commit

Permalink
register class_exists as annotation autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Sep 22, 2016
1 parent b5f5fbb commit d64f642
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ use Slim\App;
// Loaded from a file
$settings = [
'entity_manager' => [
'annotation_autoloaders' => ['class_exists'],
'connection' => [
'driver' => 'pdo_sqlite',
'memory' => true,
Expand Down Expand Up @@ -138,6 +139,7 @@ $settings = [
],
],
'secondaryDocumentManager' => [
'annotation_autoloaders' => ['class_exists'],
'connection' => [
'server' => 'mongodb://localhost:27017',
],
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"require": {
"php": ">=5.6",
"slim/slim": "^3.0",
"juliangut/doctrine-manager-builder": "^1.0"
"juliangut/doctrine-manager-builder": "^1.0.2"
},
"require-dev": {
"phpmd/phpmd": "^2.0",
Expand Down
9 changes: 8 additions & 1 deletion src/ManagerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Jgut\Slim\Doctrine;

use Doctrine\Common\Annotations\AnnotationRegistry;
use Jgut\Doctrine\ManagerBuilder\CouchDBBuilder;
use Jgut\Doctrine\ManagerBuilder\ManagerBuilder as Builder;
use Jgut\Doctrine\ManagerBuilder\MongoDBBuilder;
Expand Down Expand Up @@ -155,12 +156,16 @@ public function addBuilder(Builder $builder)
*/
public function getManagers()
{
return array_map(
$managers = array_map(
function (Builder $builder) {
return $builder->getManager();
},
$this->builders
);

AnnotationRegistry::registerLoader('class_exists');

return $managers;
}

/**
Expand Down Expand Up @@ -199,6 +204,8 @@ public function getCLIApplication()
}
}

AnnotationRegistry::registerLoader('class_exists');

return $application;
}
}

0 comments on commit d64f642

Please sign in to comment.