From bf6655a534a6775d30cafa67bd801276bda1d98d Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 13 Aug 2024 23:45:21 +0200 Subject: =?UTF-8?q?VERSION=200.2=20doctrine=20ORM=20et=20entit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/doctrine/orm/src/Id/SequenceGenerator.php | 112 +++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 vendor/doctrine/orm/src/Id/SequenceGenerator.php (limited to 'vendor/doctrine/orm/src/Id/SequenceGenerator.php') diff --git a/vendor/doctrine/orm/src/Id/SequenceGenerator.php b/vendor/doctrine/orm/src/Id/SequenceGenerator.php new file mode 100644 index 0000000..659bb58 --- /dev/null +++ b/vendor/doctrine/orm/src/Id/SequenceGenerator.php @@ -0,0 +1,112 @@ +maxValue === null || $this->nextValue === $this->maxValue) { + // Allocate new values + $connection = $em->getConnection(); + $sql = $connection->getDatabasePlatform()->getSequenceNextValSQL($this->sequenceName); + + if ($connection instanceof PrimaryReadReplicaConnection) { + $connection->ensureConnectedToPrimary(); + } + + $this->nextValue = (int) $connection->fetchOne($sql); + $this->maxValue = $this->nextValue + $this->allocationSize; + } + + return $this->nextValue++; + } + + /** + * Gets the maximum value of the currently allocated bag of values. + */ + public function getCurrentMaxValue(): int|null + { + return $this->maxValue; + } + + /** + * Gets the next value that will be returned by generate(). + */ + public function getNextValue(): int + { + return $this->nextValue; + } + + /** @deprecated without replacement. */ + final public function serialize(): string + { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11468', + '%s() is deprecated, use __serialize() instead. %s won\'t implement the Serializable interface anymore in ORM 4.', + __METHOD__, + self::class, + ); + + return serialize($this->__serialize()); + } + + /** @return array */ + public function __serialize(): array + { + return [ + 'allocationSize' => $this->allocationSize, + 'sequenceName' => $this->sequenceName, + ]; + } + + /** @deprecated without replacement. */ + final public function unserialize(string $serialized): void + { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11468', + '%s() is deprecated, use __unserialize() instead. %s won\'t implement the Serializable interface anymore in ORM 4.', + __METHOD__, + self::class, + ); + + $this->__unserialize(unserialize($serialized)); + } + + /** @param array $data */ + public function __unserialize(array $data): void + { + $this->sequenceName = $data['sequenceName']; + $this->allocationSize = $data['allocationSize']; + } +} -- cgit v1.2.3