예제 #1
0
 /**
  * @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);
     }
 }
예제 #2
0
 public function add(Invoice $invoice)
 {
     $this->eventStore->apply(new EventStream\Name(Invoice::class), $invoice->getRecordedEvents());
 }