mailpoet
/
vendor-prefixed
/
doctrine
/
dbal
/
src
/
Schema
/
Visitor
/
CreateSchemaSqlCollector.php
AbstractVisitor.php
2 years ago
CreateSchemaSqlCollector.php
2 years ago
DropSchemaSqlCollector.php
9 months ago
Graphviz.php
2 years ago
NamespaceVisitor.php
2 years ago
RemoveNamespacedAssets.php
2 years ago
Visitor.php
2 years ago
index.php
2 years ago
CreateSchemaSqlCollector.php
56 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Doctrine\DBAL\Schema\Visitor; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Schema\ForeignKeyConstraint; |
| 6 | use MailPoetVendor\Doctrine\DBAL\Schema\Sequence; |
| 7 | use MailPoetVendor\Doctrine\DBAL\Schema\Table; |
| 8 | use MailPoetVendor\Doctrine\Deprecations\Deprecation; |
| 9 | use function array_merge; |
| 10 | class CreateSchemaSqlCollector extends AbstractVisitor |
| 11 | { |
| 12 | private array $createNamespaceQueries = []; |
| 13 | private array $createTableQueries = []; |
| 14 | private array $createSequenceQueries = []; |
| 15 | private array $createFkConstraintQueries = []; |
| 16 | private AbstractPlatform $platform; |
| 17 | public function __construct(AbstractPlatform $platform) |
| 18 | { |
| 19 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5416', 'CreateSchemaSqlCollector is deprecated. Use CreateSchemaObjectsSQLBuilder instead.'); |
| 20 | $this->platform = $platform; |
| 21 | } |
| 22 | public function acceptNamespace($namespaceName) |
| 23 | { |
| 24 | if (!$this->platform->supportsSchemas()) { |
| 25 | return; |
| 26 | } |
| 27 | $this->createNamespaceQueries[] = $this->platform->getCreateSchemaSQL($namespaceName); |
| 28 | } |
| 29 | public function acceptTable(Table $table) |
| 30 | { |
| 31 | $this->createTableQueries = array_merge($this->createTableQueries, $this->platform->getCreateTableSQL($table)); |
| 32 | } |
| 33 | public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) |
| 34 | { |
| 35 | if (!$this->platform->supportsForeignKeyConstraints()) { |
| 36 | return; |
| 37 | } |
| 38 | $this->createFkConstraintQueries[] = $this->platform->getCreateForeignKeySQL($fkConstraint, $localTable); |
| 39 | } |
| 40 | public function acceptSequence(Sequence $sequence) |
| 41 | { |
| 42 | $this->createSequenceQueries[] = $this->platform->getCreateSequenceSQL($sequence); |
| 43 | } |
| 44 | public function resetQueries() |
| 45 | { |
| 46 | $this->createNamespaceQueries = []; |
| 47 | $this->createTableQueries = []; |
| 48 | $this->createSequenceQueries = []; |
| 49 | $this->createFkConstraintQueries = []; |
| 50 | } |
| 51 | public function getQueries() |
| 52 | { |
| 53 | return array_merge($this->createNamespaceQueries, $this->createSequenceQueries, $this->createTableQueries, $this->createFkConstraintQueries); |
| 54 | } |
| 55 | } |
| 56 |