Moved annotation use back into RepositoryManager
This commit is contained in:
parent
77a73b1db6
commit
231e3a0b06
3 changed files with 37 additions and 22 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace FOQ\ElasticaBundle\Manager;
|
||||
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use FOQ\ElasticaBundle\Finder\FinderInterface;
|
||||
use RuntimeException;
|
||||
/**
|
||||
|
|
@ -14,6 +15,12 @@ class RepositoryManager implements RepositoryManagerInterface
|
|||
{
|
||||
protected $entities = array();
|
||||
protected $repositories = array();
|
||||
protected $reader;
|
||||
|
||||
public function __construct(Reader $reader)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
}
|
||||
|
||||
public function addEntity($entityName, FinderInterface $finder, $repositoryName = null)
|
||||
{
|
||||
|
|
@ -53,6 +60,15 @@ class RepositoryManager implements RepositoryManagerInterface
|
|||
if (isset($this->entities[$realEntityName]['repositoryName'])) {
|
||||
return $this->entities[$realEntityName]['repositoryName'];
|
||||
}
|
||||
|
||||
$refClass = new \ReflectionClass($realEntityName);
|
||||
$annotation = $this->reader->getClassAnnotation($refClass, 'FOQ\\ElasticaBundle\\Configuration\\Search');
|
||||
if ($annotation) {
|
||||
$this->entities[$realEntityName]['repositoryName']
|
||||
= $annotation->repositoryClass;
|
||||
return $annotation->repositoryClass;
|
||||
}
|
||||
|
||||
return 'FOQ\ElasticaBundle\Repository';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue