Cache
9 months ago
Decorator
9 months ago
Event
9 months ago
Exception
9 months ago
Id
9 months ago
Internal
9 months ago
Mapping
9 months ago
Persisters
8 months ago
Proxy
9 months ago
Query
9 months ago
Repository
9 months ago
Tools
9 months ago
Utility
9 months ago
AbstractQuery.php
9 months ago
Cache.php
9 months ago
Configuration.php
9 months ago
EntityManager.php
9 months ago
EntityManagerInterface.php
9 months ago
EntityNotFoundException.php
9 months ago
EntityRepository.php
9 months ago
Events.php
9 months ago
LazyCriteriaCollection.php
9 months ago
NativeQuery.php
9 months ago
NoResultException.php
9 months ago
NonUniqueResultException.php
9 months ago
ORMException.php
9 months ago
ORMInvalidArgumentException.php
9 months ago
ORMSetup.php
9 months ago
OptimisticLockException.php
9 months ago
PersistentCollection.php
9 months ago
PessimisticLockException.php
9 months ago
Query.php
9 months ago
QueryBuilder.php
9 months ago
TransactionRequiredException.php
9 months ago
UnexpectedResultException.php
9 months ago
UnitOfWork.php
9 months ago
Version.php
9 months ago
index.php
9 months ago
OptimisticLockException.php
34 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use DateTimeInterface; |
| 6 | use MailPoetVendor\Doctrine\ORM\Exception\ORMException; |
| 7 | class OptimisticLockException extends ORMException |
| 8 | { |
| 9 | private $entity; |
| 10 | public function __construct($msg, $entity) |
| 11 | { |
| 12 | parent::__construct($msg); |
| 13 | $this->entity = $entity; |
| 14 | } |
| 15 | public function getEntity() |
| 16 | { |
| 17 | return $this->entity; |
| 18 | } |
| 19 | public static function lockFailed($entity) |
| 20 | { |
| 21 | return new self('The optimistic lock on an entity failed.', $entity); |
| 22 | } |
| 23 | public static function lockFailedVersionMismatch($entity, $expectedLockVersion, $actualLockVersion) |
| 24 | { |
| 25 | $expectedLockVersion = $expectedLockVersion instanceof DateTimeInterface ? $expectedLockVersion->getTimestamp() : $expectedLockVersion; |
| 26 | $actualLockVersion = $actualLockVersion instanceof DateTimeInterface ? $actualLockVersion->getTimestamp() : $actualLockVersion; |
| 27 | return new self('The optimistic lock failed, version ' . $expectedLockVersion . ' was expected, but is actually ' . $actualLockVersion, $entity); |
| 28 | } |
| 29 | public static function notVersioned($entityName) |
| 30 | { |
| 31 | return new self('Cannot obtain optimistic lock on unversioned entity ' . $entityName, null); |
| 32 | } |
| 33 | } |
| 34 |