Exception
2 years ago
Visitor
9 months ago
AbstractAsset.php
2 years ago
AbstractSchemaManager.php
9 months ago
Column.php
2 years ago
ColumnDiff.php
2 years ago
Comparator.php
2 years ago
Constraint.php
2 years ago
DB2SchemaManager.php
2 years ago
DefaultSchemaManagerFactory.php
2 years ago
ForeignKeyConstraint.php
9 months ago
Identifier.php
2 years ago
Index.php
2 years ago
LegacySchemaManagerFactory.php
2 years ago
MySQLSchemaManager.php
9 months ago
OracleSchemaManager.php
2 years ago
PostgreSQLSchemaManager.php
9 months ago
SQLServerSchemaManager.php
9 months ago
Schema.php
2 years ago
SchemaConfig.php
2 years ago
SchemaDiff.php
2 years ago
SchemaException.php
2 years ago
SchemaManagerFactory.php
2 years ago
Sequence.php
2 years ago
SqliteSchemaManager.php
8 months ago
Table.php
2 years ago
TableDiff.php
2 years ago
UniqueConstraint.php
2 years ago
View.php
2 years ago
Sequence.php
80 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Doctrine\DBAL\Schema; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Doctrine\DBAL\Schema\Visitor\Visitor; |
| 5 | use MailPoetVendor\Doctrine\Deprecations\Deprecation; |
| 6 | use function count; |
| 7 | use function sprintf; |
| 8 | class Sequence extends AbstractAsset |
| 9 | { |
| 10 | protected $allocationSize = 1; |
| 11 | protected $initialValue = 1; |
| 12 | protected $cache; |
| 13 | public function __construct($name, $allocationSize = 1, $initialValue = 1, $cache = null) |
| 14 | { |
| 15 | $this->_setName($name); |
| 16 | $this->setAllocationSize($allocationSize); |
| 17 | $this->setInitialValue($initialValue); |
| 18 | $this->cache = $cache; |
| 19 | } |
| 20 | public function getAllocationSize() |
| 21 | { |
| 22 | return $this->allocationSize; |
| 23 | } |
| 24 | public function getInitialValue() |
| 25 | { |
| 26 | return $this->initialValue; |
| 27 | } |
| 28 | public function getCache() |
| 29 | { |
| 30 | return $this->cache; |
| 31 | } |
| 32 | public function setAllocationSize($allocationSize) |
| 33 | { |
| 34 | if ($allocationSize > 0) { |
| 35 | $this->allocationSize = $allocationSize; |
| 36 | } else { |
| 37 | $this->allocationSize = 1; |
| 38 | } |
| 39 | return $this; |
| 40 | } |
| 41 | public function setInitialValue($initialValue) |
| 42 | { |
| 43 | if ($initialValue > 0) { |
| 44 | $this->initialValue = $initialValue; |
| 45 | } else { |
| 46 | $this->initialValue = 1; |
| 47 | } |
| 48 | return $this; |
| 49 | } |
| 50 | public function setCache($cache) |
| 51 | { |
| 52 | $this->cache = $cache; |
| 53 | return $this; |
| 54 | } |
| 55 | public function isAutoIncrementsFor(Table $table) |
| 56 | { |
| 57 | $primaryKey = $table->getPrimaryKey(); |
| 58 | if ($primaryKey === null) { |
| 59 | return \false; |
| 60 | } |
| 61 | $pkColumns = $primaryKey->getColumns(); |
| 62 | if (count($pkColumns) !== 1) { |
| 63 | return \false; |
| 64 | } |
| 65 | $column = $table->getColumn($pkColumns[0]); |
| 66 | if (!$column->getAutoincrement()) { |
| 67 | return \false; |
| 68 | } |
| 69 | $sequenceName = $this->getShortestName($table->getNamespaceName()); |
| 70 | $tableName = $table->getShortestName($table->getNamespaceName()); |
| 71 | $tableSequenceName = sprintf('%s_%s_seq', $tableName, $column->getShortestName($table->getNamespaceName())); |
| 72 | return $tableSequenceName === $sequenceName; |
| 73 | } |
| 74 | public function visit(Visitor $visitor) |
| 75 | { |
| 76 | Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5435', 'Sequence::visit() is deprecated.'); |
| 77 | $visitor->acceptSequence($this); |
| 78 | } |
| 79 | } |
| 80 |