‪TYPO3CMS  ‪main
CoreSchemaManagerFactory.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\Connection;
21 use Doctrine\DBAL\Platforms\AbstractMySQLPlatform as DoctrineAbstractMySQLPlatform;
22 use Doctrine\DBAL\Platforms\MariaDBPlatform as DoctrineMariaDBPlatform;
23 use Doctrine\DBAL\Platforms\MySQLPlatform as DoctrineMySQLPlatform;
24 use Doctrine\DBAL\Platforms\PostgreSQLPlatform as DoctrinePostgreSQLPlatform;
25 use Doctrine\DBAL\Platforms\SQLitePlatform as DoctrineSQLitePlatform;
26 use Doctrine\DBAL\Schema\AbstractSchemaManager;
27 use Doctrine\DBAL\Schema\SchemaManagerFactory;
28 
42 final class ‪CoreSchemaManagerFactory implements SchemaManagerFactory
43 {
44  public function ‪createSchemaManager(Connection $connection): AbstractSchemaManager
45  {
46  $platform = $connection->getDatabasePlatform();
47  // Platform specific SchemaManager are extended to manipulate the schema handling. TYPO3 needs to
48  // do that to provide additional doctrine type handling and other workarounds or alignments. Long
49  // time this have been done by using the `doctrine EventManager` to hook into several places, which
50  // no longer exists.
51  //
52  // @link https://github.com/doctrine/dbal/blob/3.7.x/UPGRADE.md#deprecated-not-setting-a-schema-manager-factory
53  // @link https://github.com/doctrine/dbal/blob/3.7.x/UPGRADE.md#deprecated-extension-via-doctrine-event-manager
54  // @todo Consider make check on SchemaManager instance retrieved from $platform->createSchemaManager()
55  return match (true) {
56  $platform instanceof DoctrineSQLitePlatform => new ‪SQLiteSchemaManager($connection, $platform),
57  $platform instanceof DoctrinePostgreSQLPlatform => new ‪PostgreSQLSchemaManager($connection, $platform),
58  $platform instanceof DoctrineMariaDBPlatform,
59  $platform instanceof DoctrineMySQLPlatform,
60  $platform instanceof DoctrineAbstractMySQLPlatform => new ‪MySQLSchemaManager($connection, $platform),
61  default => $platform->createSchemaManager($connection),
62  };
63  }
64 }
‪TYPO3\CMS\Core\Database\Schema\SchemaManager\MySQLSchemaManager
Definition: MySQLSchemaManager.php:50
‪TYPO3\CMS\Core\Database\Schema\SchemaManager\CoreSchemaManagerFactory
Definition: CoreSchemaManagerFactory.php:43
‪TYPO3\CMS\Core\Database\Schema\SchemaManager\CoreSchemaManagerFactory\createSchemaManager
‪createSchemaManager(Connection $connection)
Definition: CoreSchemaManagerFactory.php:44
‪TYPO3\CMS\Core\Database\Schema\SchemaManager\SQLiteSchemaManager
Definition: SQLiteSchemaManager.php:41
‪TYPO3\CMS\Core\Database\Schema\SchemaManager
Definition: CoreSchemaManagerFactory.php:18
‪TYPO3\CMS\Core\Database\Schema\SchemaManager\PostgreSQLSchemaManager
Definition: PostgreSQLSchemaManager.php:42