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/AbstractIdGenerator.php | 28 ++++++ vendor/doctrine/orm/src/Id/AssignedGenerator.php | 45 +++++++++ .../orm/src/Id/BigIntegerIdentityGenerator.php | 25 +++++ vendor/doctrine/orm/src/Id/IdentityGenerator.php | 25 +++++ vendor/doctrine/orm/src/Id/SequenceGenerator.php | 112 +++++++++++++++++++++ 5 files changed, 235 insertions(+) create mode 100644 vendor/doctrine/orm/src/Id/AbstractIdGenerator.php create mode 100644 vendor/doctrine/orm/src/Id/AssignedGenerator.php create mode 100644 vendor/doctrine/orm/src/Id/BigIntegerIdentityGenerator.php create mode 100644 vendor/doctrine/orm/src/Id/IdentityGenerator.php create mode 100644 vendor/doctrine/orm/src/Id/SequenceGenerator.php (limited to 'vendor/doctrine/orm/src/Id') diff --git a/vendor/doctrine/orm/src/Id/AbstractIdGenerator.php b/vendor/doctrine/orm/src/Id/AbstractIdGenerator.php new file mode 100644 index 0000000..6d981f8 --- /dev/null +++ b/vendor/doctrine/orm/src/Id/AbstractIdGenerator.php @@ -0,0 +1,28 @@ +getClassMetadata($entity::class); + $idFields = $class->getIdentifierFieldNames(); + $identifier = []; + + foreach ($idFields as $idField) { + $value = $class->getFieldValue($entity, $idField); + + if (! isset($value)) { + throw EntityMissingAssignedId::forField($entity, $idField); + } + + if (isset($class->associationMappings[$idField])) { + // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced. + $value = $em->getUnitOfWork()->getSingleIdentifierValue($value); + } + + $identifier[$idField] = $value; + } + + return $identifier; + } +} diff --git a/vendor/doctrine/orm/src/Id/BigIntegerIdentityGenerator.php b/vendor/doctrine/orm/src/Id/BigIntegerIdentityGenerator.php new file mode 100644 index 0000000..762a7cb --- /dev/null +++ b/vendor/doctrine/orm/src/Id/BigIntegerIdentityGenerator.php @@ -0,0 +1,25 @@ +getConnection()->lastInsertId(); + } + + public function isPostInsertGenerator(): bool + { + return true; + } +} diff --git a/vendor/doctrine/orm/src/Id/IdentityGenerator.php b/vendor/doctrine/orm/src/Id/IdentityGenerator.php new file mode 100644 index 0000000..4610f66 --- /dev/null +++ b/vendor/doctrine/orm/src/Id/IdentityGenerator.php @@ -0,0 +1,25 @@ +getConnection()->lastInsertId(); + } + + public function isPostInsertGenerator(): bool + { + return true; + } +} 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