public function conflictsWith(AggregateRootEventInterface $event, array &$conflicting_changes = [])
 {
     if ($event->getAggregateRootIdentifier() !== $this->getAggregateRootIdentifier()) {
         return false;
     }
     if ($event instanceof AggregateRootNodeMovedEvent) {
         if ($event->getParentNodeId() !== $this->getParentNodeId()) {
             $conflicting_changes['parent_node_id'] = $event->getParentNodeId();
             return true;
         }
     }
     return false;
 }
 public function conflictsWith(AggregateRootEventInterface $event, array &$conflicting_changes = [])
 {
     if ($event->getAggregateRootIdentifier() !== $this->getAggregateRootIdentifier()) {
         return false;
     }
     $conflict_detected = false;
     if ($event instanceof WorkflowProceededEvent) {
         // workflow events always conflict as there is no way to know,
         // that the employed modification is still valid within the new workflow-state.
         $conflict_detected = true;
     } elseif ($event instanceof AggregateRootModifiedEvent) {
         // concurrent modifications can be resolved,
         // if they dont alter the same attributes or employ equal modifications.
         $event_changes = $event->getData();
         foreach ($this->getValues() as $attribute_name => $attribute_value) {
             if (array_key_exists($attribute_name, $event_changes) && $event_changes[$attribute_name] != $this->values[$attribute_name]) {
                 $conflicting_changes[$attribute_name] = $attribute_value;
                 $conflict_detected = true;
             }
         }
     }
     return $conflict_detected;
 }
Example #3
0
 protected function guardEventPreConditions(AggregateRootEventInterface $event)
 {
     if (!$event instanceof AggregateRootCreatedEvent && $this->getIdentifier() !== $event->getAggregateRootIdentifier()) {
         throw new RuntimeError(sprintf('The AR\'s current identifier (%s) does not match the given event\'s AR identifier (%s).', $this->getIdentifier(), $event->getAggregateRootIdentifier()));
     }
     if (!$event instanceof AggregateRootCreatedEvent && !$event instanceof AggregateRootModifiedEvent) {
         throw new RuntimeError(sprintf('Unsupported domain event-type "%s" given. Supported event-types are: %s.', get_class($event), implode(', ', [AggregateRootCreatedEvent::CLASS, AggregateRootModifiedEvent::CLASS])));
     }
     $last_event = $this->getHistory()->getLast();
     if ($last_event && $event->getSeqNumber() !== $this->getRevision() + 1) {
         throw new RuntimeError(sprintf('Invalid sequence-number. ' . 'The given event sequence-number(%d) must be incremental relative to the known-revision(%s).', $event->getSeqNumber(), $this->getRevision()));
     }
 }
 public function conflictsWith(AggregateRootEventInterface $event, array &$conflicting_changes = [])
 {
     return $event->getAggregateRootIdentifier() === $this->getAggregateRootIdentifier() && $event instanceof WorkflowProceededEvent;
 }
Example #5
0
 protected function getProjectionType(AggregateRootEventInterface $event)
 {
     return $this->projection_type_map->getByAggregateRootType($this->aggregate_root_type_map->getItem($event->getAggregateRootType()));
 }