/** * {@inheritdoc} */ public function commit(EventStream $eventStream) { /** @var Message $envelope */ foreach ($eventStream as $envelope) { $this->messageRecorder->record($envelope); } $this->next->commit($eventStream); }
/** * {@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); }
/** * {@inheritdoc} */ public function commit(EventStream $eventStream) { $enrichedEnvelopes = []; /** @var EnvelopsEvent $envelope */ foreach ($eventStream as $envelope) { foreach ($this->metadataEnrichers as $metadataEnricher) { $envelope = $metadataEnricher->enrich($envelope); } $enrichedEnvelopes[] = $envelope; } $this->next->commit(new EventStream($eventStream->aggregateId(), $enrichedEnvelopes)); }