wiki.techinc.nl/includes/libs/rdbms/database/DoctrineSchemaBuilderFactory.php
Amir Sarabadani 30c4b22d4e Start of DoctrineSchemaBuilder
This allows us to abstract away schemas into one json file.

Bug: T230419
Change-Id: Ic8a658c97150e4c248bdbc9a5cf5d947b8c71036
2019-11-09 21:32:32 +00:00

32 lines
842 B
PHP

<?php
namespace Wikimedia\Rdbms;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use InvalidArgumentException;
/**
* @experimental
* @unstable
*/
class DoctrineSchemaBuilderFactory {
/**
* @param string $platform one of strings 'mysql', 'postgres' or 'sqlite'
* @return DoctrineSchemaBuilder
*/
public function getSchemaBuilder( $platform ) {
if ( $platform === 'mysql' ) {
$platformObject = new MySqlPlatform();
} elseif ( $platform === 'postgres' ) {
$platformObject = new PostgreSqlPlatform();
} elseif ( $platform === 'sqlite' ) {
$platformObject = new SqlitePlatform();
} else {
throw new InvalidArgumentException( 'Unknown platform: ' . $platform );
}
return new DoctrineSchemaBuilder( $platformObject );
}
}