DbalMigrationFactory.php 866 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Migrations\Version;
  4. use Doctrine\DBAL\Connection;
  5. use Doctrine\Migrations\AbstractMigration;
  6. use Psr\Log\LoggerInterface;
  7. /**
  8. * The DbalMigrationFactory class is responsible for creating instances of a migration class name for a DBAL connection.
  9. *
  10. * @internal
  11. */
  12. final class DbalMigrationFactory implements MigrationFactory
  13. {
  14. /** @var Connection */
  15. private $connection;
  16. /** @var LoggerInterface */
  17. private $logger;
  18. public function __construct(Connection $connection, LoggerInterface $logger)
  19. {
  20. $this->connection = $connection;
  21. $this->logger = $logger;
  22. }
  23. public function createVersion(string $migrationClassName): AbstractMigration
  24. {
  25. return new $migrationClassName(
  26. $this->connection,
  27. $this->logger
  28. );
  29. }
  30. }