/** * @param Event $event * @throws Exception\NoAggregateRootRegistered */ protected function apply(Event $event) { if (!$this->aggregateRoot) { throw new Exception\NoAggregateRootRegistered(); } $this->aggregateRoot->apply($event); }
/** * @param AggregateRootInterface $aggregate * @return void */ public function save(AggregateRootInterface $aggregate) { $events = $aggregate->getUncommittedEvents(); $this->eventStore->append($aggregate->getAggregateRootId(), $events); $this->eventBus->publish($events); }