Skip to content

Commit

Permalink
Support user defined repositories
Browse files Browse the repository at this point in the history
A verification was done with EntityRepository inheritance. This commit drop it in
favor of a check on interface ObjectRepository which allow user to define its own
complete repository.
  • Loading branch information
Nek- committed Oct 11, 2018
1 parent a03386c commit f0dd12e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Repository/ContainerRepositoryFactory.php
Expand Up @@ -50,8 +50,15 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName
if ($this->container && $this->container->has($customRepositoryName)) {
$repository = $this->container->get($customRepositoryName);

if (! $repository instanceof EntityRepository) {
throw new \RuntimeException(sprintf('The service "%s" must extend EntityRepository (or a base class, like ServiceEntityRepository).', $repositoryServiceId));
if (\interface_exists(ObjectRepository::class)) {
if (!$repository instanceof ObjectRepository) {
throw new \RuntimeException(sprintf('The service "%s" must implement ObjectRepository (or extend a base class, like ServiceEntityRepository).', $repositoryServiceId));
}
} else {
// Doctrine 2.4 compatibility layer
if (!$repository instanceof EntityRepository) {
throw new \RuntimeException(sprintf('The service "%s" must implement ObjectRepository (or extend a base class, like ServiceEntityRepository).', $repositoryServiceId));
}
}

return $repository;
Expand Down

0 comments on commit f0dd12e

Please sign in to comment.