protected function doSaveWithLock(AggregateRootInterface $aggregate)
 {
     if (null !== $this->eventStore) {
         $this->eventStore->appendEvents($this->getTypeIdentifier(), $aggregate->getUncommittedEvents());
     }
     parent::doSaveWithLock($aggregate);
 }
 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;
 }
 protected function validateOnLoad(AggregateRootInterface $object, $expectedVersion)
 {
     if (null !== $expectedVersion && null !== $object->getVersion() && $expectedVersion !== $object->getVersion()) {
         throw new ConflictingAggregateVersionException($object->getIdentifier(), $expectedVersion, $object->getVersion());
     }
 }
 protected function doSaveWithLock(AggregateRootInterface $aggregate)
 {
     $this->store[$aggregate->getIdentifier()] = $aggregate;
     $this->saveCount++;
 }
 private function validateIdentifier($aggregateIdentifier, AggregateRootInterface $aggregate)
 {
     if (null !== $aggregateIdentifier && !$aggregateIdentifier === $aggregate->getIdentifier()) {
         throw new \RuntimeException(sprintf("The aggregate used in this fixture was initialized with an identifier different than " . "the one used to load it. Loaded [%s], but actual identifier is [%s].\n" . "Make sure the identifier passed in the Command matches that of the given Events.", $aggregateIdentifier, $aggregate->getIdentifier()));
     }
 }
 protected function doSaveWithLock(AggregateRootInterface $aggregate)
 {
     $eventStream = $aggregate->getUncommittedEvents();
     $iterator = new \ArrayIterator(array_reverse($this->eventStreamDecorators));
     while ($iterator->valid()) {
         $eventStream = $iterator->current()->decorateForAppend($this->getTypeIdentifier(), $aggregate, $eventStream);
         $iterator->next();
     }
     $this->eventStore->appendEvents($this->getTypeIdentifier(), $eventStream);
 }