コード例 #1
0
ファイル: IdentityMap.php プロジェクト: f500/event-sourcing
 /**
  * {@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;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function add(TracksEvents $aggregate)
 {
     if (!$this->identityMap->contains($aggregate->aggregateId())) {
         $this->identityMap->add($aggregate);
     }
     $this->repository->add($aggregate);
 }
コード例 #3
0
 /**
  * {@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);
 }