/**
  * @param object $command
  * @param callable $next
  *
  * @return mixed
  */
 public function execute($command, callable $next)
 {
     $next($command);
     $unncommitedEventStreams = [];
     foreach ($this->streamNames as $streamName) {
         $unncommitedEventStreams[] = $this->eventStore->findUncommited(new EventStream\Name($streamName));
     }
     $this->eventStore->commit();
     foreach ($unncommitedEventStreams as $eventStream) {
         $this->eventBus->notify($eventStream);
     }
 }
Exemple #2
0
 public function add(Invoice $invoice)
 {
     $this->eventStore->apply(new EventStream\Name(Invoice::class), $invoice->getRecordedEvents());
 }