Extracted method in RepositoryManager

This commit is contained in:
Richard Miller 2012-01-25 12:42:02 +00:00
commit 9c0d7dd622

View file

@ -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']);
}
}