-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "chore: remove getPlatformName()"
This reverts commit 1894de4.
- Loading branch information
1 parent
2f0ecae
commit 2ca04d2
Showing
3 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Liip/TestFixturesBundle | ||
* | ||
* (c) Lukas Kahwe Smith <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Liip\TestFixturesBundle\Services\DatabaseTools; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; | ||
use Doctrine\DBAL\Platforms\MySqlPlatform; | ||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | ||
use Doctrine\DBAL\Platforms\SqlitePlatform; | ||
|
||
abstract class AbstractDbalDatabaseTool extends AbstractDatabaseTool | ||
{ | ||
protected Connection $connection; | ||
|
||
public function setObjectManagerName(?string $omName = null): void | ||
{ | ||
parent::setObjectManagerName($omName); | ||
$this->connection = $this->registry->getConnection($omName); | ||
} | ||
|
||
protected function getPlatformName(): string | ||
{ | ||
$platform = $this->connection->getDatabasePlatform(); | ||
|
||
// AbstractMySQLPlatform was introduced in DBAL 3.3, keep the MySQLPlatform checks for compatibility with older versions | ||
if ($platform instanceof AbstractMySQLPlatform || $platform instanceof MySqlPlatform) { | ||
return 'mysql'; | ||
} elseif ($platform instanceof SqlitePlatform) { | ||
return 'sqlite'; | ||
} elseif ($platform instanceof PostgreSQLPlatform) { | ||
return 'pgsql'; | ||
} | ||
|
||
return (new \ReflectionClass($platform))->getShortName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
use Doctrine\Common\DataFixtures\Executor\ORMExecutor; | ||
use Doctrine\Common\DataFixtures\ProxyReferenceRepository; | ||
use Doctrine\Common\DataFixtures\Purger\ORMPurger; | ||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\DriverManager; | ||
use Doctrine\DBAL\Platforms\MySqlPlatform; | ||
use Doctrine\ORM\Configuration; | ||
|
@@ -32,7 +31,7 @@ | |
/** | ||
* @author Aleksey Tupichenkov <[email protected]> | ||
*/ | ||
class ORMDatabaseTool extends AbstractDatabaseTool | ||
class ORMDatabaseTool extends AbstractDbalDatabaseTool | ||
{ | ||
/** | ||
* @var EntityManager | ||
|
@@ -44,14 +43,6 @@ class ORMDatabaseTool extends AbstractDatabaseTool | |
*/ | ||
private $shouldEnableForeignKeyChecks = false; | ||
|
||
protected Connection $connection; | ||
|
||
public function setObjectManagerName(?string $omName = null): void | ||
{ | ||
parent::setObjectManagerName($omName); | ||
$this->connection = $this->registry->getConnection($omName); | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return 'ORM'; | ||
|