vendor/doctrine/doctrine-bundle/Repository/RepositoryFactoryCompatibility.php line 38

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\Repository;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Doctrine\ORM\EntityRepository;
  5. use Doctrine\ORM\Repository\RepositoryFactory;
  6. use Doctrine\Persistence\ObjectRepository;
  7. use ReflectionMethod;
  8. if ((new ReflectionMethod(RepositoryFactory::class, 'getRepository'))->hasReturnType()) {
  9.     // ORM >= 3
  10.     /** @internal */
  11.     trait RepositoryFactoryCompatibility
  12.     {
  13.         /**
  14.          * Gets the repository for an entity class.
  15.          *
  16.          * @param class-string<T> $entityName
  17.          *
  18.          * @return EntityRepository<T>
  19.          *
  20.          * @template T of object
  21.          */
  22.         public function getRepository(EntityManagerInterface $entityManagerstring $entityName): EntityRepository
  23.         {
  24.             return $this->doGetRepository($entityManager$entityNametrue);
  25.         }
  26.     }
  27. } else {
  28.     // ORM 2
  29.     /** @internal */
  30.     trait RepositoryFactoryCompatibility
  31.     {
  32.         /** {@inheritDoc} */
  33.         public function getRepository(EntityManagerInterface $entityManager$entityName): ObjectRepository
  34.         {
  35.             return $this->doGetRepository($entityManager$entityNamefalse);
  36.         }
  37.     }
  38. }