diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-18 00:08:23 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-18 00:10:03 +0200 |
| commit | 05e38eadbeb3de19e5b26003c2b401e00bb71df4 (patch) | |
| tree | cf48350b69cfce92de6f3a0e03eb0876931c7077 /vendor/doctrine/orm/src/OptimisticLockException.php | |
| parent | 32843e50aa981f190bdb4fbc9adbeacc06fdf775 (diff) | |
| download | AppliGestionPHP-05e38eadbeb3de19e5b26003c2b401e00bb71df4.tar.gz AppliGestionPHP-05e38eadbeb3de19e5b26003c2b401e00bb71df4.tar.bz2 AppliGestionPHP-05e38eadbeb3de19e5b26003c2b401e00bb71df4.zip | |
sortie de vendor du dépôt, oubli dans config-template.ini
Diffstat (limited to 'vendor/doctrine/orm/src/OptimisticLockException.php')
| -rw-r--r-- | vendor/doctrine/orm/src/OptimisticLockException.php | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/vendor/doctrine/orm/src/OptimisticLockException.php b/vendor/doctrine/orm/src/OptimisticLockException.php deleted file mode 100644 index f84e134..0000000 --- a/vendor/doctrine/orm/src/OptimisticLockException.php +++ /dev/null | |||
| @@ -1,55 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM; | ||
| 6 | |||
| 7 | use DateTimeInterface; | ||
| 8 | use Doctrine\ORM\Exception\ORMException; | ||
| 9 | use Exception; | ||
| 10 | use Throwable; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * An OptimisticLockException is thrown when a version check on an object | ||
| 14 | * that uses optimistic locking through a version field fails. | ||
| 15 | */ | ||
| 16 | class OptimisticLockException extends Exception implements ORMException | ||
| 17 | { | ||
| 18 | public function __construct( | ||
| 19 | string $msg, | ||
| 20 | private readonly object|string|null $entity, | ||
| 21 | Throwable|null $previous = null, | ||
| 22 | ) { | ||
| 23 | parent::__construct($msg, 0, $previous); | ||
| 24 | } | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Gets the entity that caused the exception. | ||
| 28 | */ | ||
| 29 | public function getEntity(): object|string|null | ||
| 30 | { | ||
| 31 | return $this->entity; | ||
| 32 | } | ||
| 33 | |||
| 34 | /** @param object|class-string $entity */ | ||
| 35 | public static function lockFailed(object|string $entity): self | ||
| 36 | { | ||
| 37 | return new self('The optimistic lock on an entity failed.', $entity); | ||
| 38 | } | ||
| 39 | |||
| 40 | public static function lockFailedVersionMismatch( | ||
| 41 | object $entity, | ||
| 42 | int|string|DateTimeInterface $expectedLockVersion, | ||
| 43 | int|string|DateTimeInterface $actualLockVersion, | ||
| 44 | ): self { | ||
| 45 | $expectedLockVersion = $expectedLockVersion instanceof DateTimeInterface ? $expectedLockVersion->getTimestamp() : $expectedLockVersion; | ||
| 46 | $actualLockVersion = $actualLockVersion instanceof DateTimeInterface ? $actualLockVersion->getTimestamp() : $actualLockVersion; | ||
| 47 | |||
| 48 | return new self('The optimistic lock failed, version ' . $expectedLockVersion . ' was expected, but is actually ' . $actualLockVersion, $entity); | ||
| 49 | } | ||
| 50 | |||
| 51 | public static function notVersioned(string $entityName): self | ||
| 52 | { | ||
| 53 | return new self('Cannot obtain optimistic lock on unversioned entity ' . $entityName, null); | ||
| 54 | } | ||
| 55 | } | ||
