Exemplo n.º 1
0
 protected function doSave(AggregateRootInterface $object)
 {
     if (null !== $object->getVersion() && !$this->lockManager->validateLock($object)) {
         throw new ConcurrencyException(sprintf("The aggregate of type [%s] with identifier [%s] could not be " . "saved, as a valid lock is not held. Either another thread has saved an aggregate, or " . "the current thread had released its lock earlier on.", get_class($object), $object->getIdentifier()));
     }
     $this->doSaveWithLock($object);
 }
 public function validate(AggregateRootInterface $aggregate)
 {
     $lastCommitedScn = $aggregate->getVersion();
     if (null === $this->versionNumber || $this->versionNumber === $lastCommitedScn) {
         $last = null === $lastCommitedScn ? 0 : $lastCommitedScn;
         $this->versionNumber = $last;
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 protected function validateOnLoad(AggregateRootInterface $object, $expectedVersion)
 {
     if (null !== $expectedVersion && null !== $object->getVersion() && $expectedVersion !== $object->getVersion()) {
         throw new ConflictingAggregateVersionException($object->getIdentifier(), $expectedVersion, $object->getVersion());
     }
 }