MediaWiki
master
Toggle main menu visibility
DoctrineSchemaBuilderFactory.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Wikimedia\Rdbms\DBAL;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Platforms\SQLitePlatform;
7
use Doctrine\DBAL\Types\Type;
8
use InvalidArgumentException;
9
14
class
DoctrineSchemaBuilderFactory
{
15
20
public
function
getSchemaBuilder
(
string
$platform ) {
21
return
new
DoctrineSchemaBuilder
( $this->getPlatform( $platform ) );
22
}
23
28
public
function
getSchemaChangeBuilder
( $platform ) {
29
return
new
DoctrineSchemaChangeBuilder
( $this->getPlatform( $platform ) );
30
}
31
36
private
function
getPlatform(
string
$platform ) {
37
$platformObject = match ( $platform ) {
38
'mysql'
=>
new
MWMySQLPlatform
(),
39
'postgres'
=>
new
MWPostgreSqlPlatform
(),
40
'sqlite'
=>
new
SQLitePlatform(),
41
default
=>
throw
new
InvalidArgumentException(
"Unknown platform: $platform"
)
42
};
43
44
$customTypes = [
45
'Enum'
=> [ EnumType::class,
EnumType::ENUM
],
46
'Tinyint'
=> [ TinyIntType::class,
TinyIntType::TINYINT
],
47
'Timestamp'
=> [ TimestampType::class,
TimestampType::TIMESTAMP
],
48
];
49
50
foreach
( $customTypes as $type => [ $class, $name ] ) {
51
if
( !Type::hasType( $name ) ) {
52
Type::addType( $name, $class );
53
}
54
$platformObject->registerDoctrineTypeMapping( $type, $name );
55
}
56
57
return
$platformObject;
58
}
59
}
Wikimedia\Rdbms\DBAL\DoctrineSchemaBuilderFactory
@experimental
Definition
DoctrineSchemaBuilderFactory.php:14
Wikimedia\Rdbms\DBAL\DoctrineSchemaBuilderFactory\getSchemaChangeBuilder
getSchemaChangeBuilder( $platform)
Definition
DoctrineSchemaBuilderFactory.php:28
Wikimedia\Rdbms\DBAL\DoctrineSchemaBuilderFactory\getSchemaBuilder
getSchemaBuilder(string $platform)
Definition
DoctrineSchemaBuilderFactory.php:20
Wikimedia\Rdbms\DBAL\DoctrineSchemaBuilder
@experimental
Definition
DoctrineSchemaBuilder.php:12
Wikimedia\Rdbms\DBAL\DoctrineSchemaChangeBuilder
@experimental
Definition
DoctrineSchemaChangeBuilder.php:14
Wikimedia\Rdbms\DBAL\EnumType\ENUM
const ENUM
Definition
EnumType.php:22
Wikimedia\Rdbms\DBAL\MWMySQLPlatform
Definition
MWMySQLPlatform.php:7
Wikimedia\Rdbms\DBAL\MWPostgreSqlPlatform
Definition
MWPostgreSqlPlatform.php:11
Wikimedia\Rdbms\DBAL\TimestampType\TIMESTAMP
const TIMESTAMP
Definition
TimestampType.php:16
Wikimedia\Rdbms\DBAL\TinyIntType\TINYINT
const TINYINT
Definition
TinyIntType.php:14
includes
libs
Rdbms
DBAL
DoctrineSchemaBuilderFactory.php
Generated on
for MediaWiki by
1.18.0