Extracted method in RepositoryManager
This commit is contained in:
parent
e00aa3a077
commit
9c0d7dd622
1 changed files with 10 additions and 5 deletions
|
|
@ -45,11 +45,7 @@ class RepositoryManager implements RepositoryManagerInterface
|
|||
throw new RuntimeException(sprintf('No search finder configured for %s', $entityName));
|
||||
}
|
||||
|
||||
$repositoryName = $this->getRepositoryName($entityName);
|
||||
if (!class_exists($repositoryName)) {
|
||||
throw new RuntimeException(sprintf('%s repository for %s does not exist', $repositoryName, $entityName));
|
||||
}
|
||||
$repository = new $repositoryName($this->entities[$entityName]['finder']);
|
||||
$repository = $this->createRepository($entityName);
|
||||
$this->repositories[$entityName] = $repository;
|
||||
|
||||
return $repository;
|
||||
|
|
@ -72,4 +68,13 @@ class RepositoryManager implements RepositoryManagerInterface
|
|||
return 'FOQ\ElasticaBundle\Repository';
|
||||
}
|
||||
|
||||
private function createRepository($entityName)
|
||||
{
|
||||
$repositoryName = $this->getRepositoryName($entityName);
|
||||
if (!class_exists($repositoryName)) {
|
||||
throw new RuntimeException(sprintf('%s repository for %s does not exist', $repositoryName, $entityName));
|
||||
}
|
||||
return new $repositoryName($this->entities[$entityName]['finder']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue