ExistingEntityManager.php 705 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Migrations\Configuration\EntityManager;
  4. use Doctrine\Migrations\Configuration\Exception\InvalidLoader;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. final class ExistingEntityManager implements EntityManagerLoader
  7. {
  8. /** @var EntityManagerInterface */
  9. private $entityManager;
  10. public function __construct(EntityManagerInterface $entityManager)
  11. {
  12. $this->entityManager = $entityManager;
  13. }
  14. public function getEntityManager(?string $name = null): EntityManagerInterface
  15. {
  16. if ($name !== null) {
  17. throw InvalidLoader::noMultipleEntityManagers($this);
  18. }
  19. return $this->entityManager;
  20. }
  21. }