/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln("Reload read store from event store."); $this->documents->clear(); $output->write("Loading aggregate identities... "); $ids = $this->events->getAggregateIds(); $output->writeln("done."); $total = count($ids); $current = 0; foreach ($ids as $id) { /* @var $id Uuid */ $eventStream = $this->events->getEventsForAggregate($id); $aggregate = new UserReplay($id); $aggregate->loadFromHistory($eventStream); $document = $this->createDocumentFromAggregate($aggregate, $eventStream->size()); $this->documents->upsert($id, $document); $output->write(sprintf("%d/%d\r", ++$current, $total)); } $output->writeln("\nDone."); }
/** * @param UserCreated $event */ public function onUserCreated(UserCreated $event) { $this->storage->upsert($event->getId()->getValue(), new User($event->getId(), $event->getUserName(), $event->getEmailAddress(), $event->getFullName(), $event->getVersion())); }
/** * @param BookReturned $event */ public function onBookReturned(BookReturned $event) { $current = $this->getBook($event->getId()); $this->storage->upsert($event->getId()->getValue(), new Book($event->getId(), $current->getAuthors(), $current->getTitle(), $current->getISBN(), true, $event->getVersion())); }