/** * @param Collection|Subscriber[] * @param string[] $events */ protected function replayEvents($projections, $events) { $eventCount = $this->eventStore->getEventCountByTypes($events); $start = 0; $take = 1000; $this->output->progressStart($eventCount); $dispatcher = $this->buildAndRegisterDispatcher($projections); while ($start < $eventCount) { foreach ($this->eventStore->getEventsByType($events, $start, $take) as $eventRow) { $this->dispatchEvent($dispatcher, $eventRow); } $start += $take; $this->output->progressAdvance($take > $eventCount ? $eventCount : $take); } $this->output->progressFinish(); $this->line(memory_get_peak_usage(true) / 1024 / 1024 . "mb Peak Usage", false); }
/** * @param AggregateRootInterface $aggregate * @return void */ public function save(AggregateRootInterface $aggregate) { $events = $aggregate->getUncommittedEvents(); $this->eventStore->append($aggregate->getAggregateRootId(), $events); $this->eventBus->publish($events); }