Skip to content

Commit

Permalink
feat: don't call deprecated method getName() on doctrine platform
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Jan 20, 2024
1 parent 0b936c0 commit be3a0cd
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/Services/DatabaseTools/AbstractDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader;
use Doctrine\Common\DataFixtures\Executor\AbstractExecutor;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;
use Liip\TestFixturesBundle\Services\DatabaseBackup\DatabaseBackupInterface;
Expand Down Expand Up @@ -58,10 +61,7 @@ abstract class AbstractDatabaseTool
*/
protected $om;

/**
* @var Connection
*/
protected $connection;
protected Connection $connection;

/**
* @var int|null
Expand Down Expand Up @@ -193,7 +193,7 @@ protected function getBackupService(): ?DatabaseBackupInterface
{
$backupServiceParamName = strtolower('liip_test_fixtures.cache_db.'.(
('ORM' === $this->getType())
? $this->connection->getDatabasePlatform()->getName()
? $this->getPlatformName()
: $this->getType()
));

Expand Down Expand Up @@ -270,4 +270,19 @@ protected function getCacheMetadataParameter()
return $this->container->hasParameter(self::CACHE_METADATA_PARAMETER_NAME)
&& false !== $this->container->getParameter(self::CACHE_METADATA_PARAMETER_NAME);
}

private function getPlatformName(): string
{
$platform = $this->connection->getDatabasePlatform();

if ($platform instanceof AbstractMySQLPlatform) {
return 'mysql';
} elseif ($platform instanceof SqlitePlatform) {
return 'sqlite';
} elseif ($platform instanceof PostgreSQLPlatform) {
return 'pgsql';
}

return (new \ReflectionClass($platform))->getShortName();
}
}

0 comments on commit be3a0cd

Please sign in to comment.