/**
  * {@inheritdoc}
  */
 public function add(TracksEvents $aggregate)
 {
     if (!$this->identityMap->contains($aggregate->aggregateId())) {
         $this->identityMap->add($aggregate);
     }
     $this->repository->add($aggregate);
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function add(TracksEvents $aggregate)
 {
     $lookupKey = $this->createLookupKey($aggregate->aggregateId());
     if (isset($this->map[$lookupKey])) {
         throw DuplicateAggregateFound::create($aggregate->aggregateId());
     }
     $this->map[$lookupKey] = $aggregate;
 }
 /**
  * {@inheritdoc}
  */
 public function add(TracksEvents $aggregate)
 {
     if (!$aggregate->hasRecordedEvents()) {
         return;
     }
     $recordedEvents = $aggregate->recordedEvents();
     $aggregate->eraseRecordedEvents();
     $envelopeStream = $this->eventWrapper->wrap($aggregate->aggregateId(), $recordedEvents);
     $this->eventStore->commit($envelopeStream);
 }