ManagerRegistryAwareConnectionProvider.php 733 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\Dbal;
  3. use Doctrine\DBAL\Connection;
  4. use Doctrine\DBAL\Tools\Console\ConnectionProvider;
  5. use Doctrine\Persistence\AbstractManagerRegistry;
  6. class ManagerRegistryAwareConnectionProvider implements ConnectionProvider
  7. {
  8. /** @var AbstractManagerRegistry */
  9. private $managerRegistry;
  10. public function __construct(AbstractManagerRegistry $managerRegistry)
  11. {
  12. $this->managerRegistry = $managerRegistry;
  13. }
  14. public function getDefaultConnection(): Connection
  15. {
  16. return $this->managerRegistry->getConnection();
  17. }
  18. public function getConnection(string $name): Connection
  19. {
  20. return $this->managerRegistry->getConnection($name);
  21. }
  22. }