Example #1
0
 /**
  * @param string $userName
  * @return User
  */
 public function getUserByUserName($userName)
 {
     $users = $this->storage->findBy(['userName' => $userName], 0, 1);
     if (count($users) == 0) {
         return null;
     }
     return reset($users);
 }
Example #2
0
 /**
  * @param integer $page
  * @param integer $size
  * @return Book[]
  */
 public function getAll($page = 1, $size = 500)
 {
     $page = max((int) $page, 1);
     $size = min((int) $size, 500);
     $offset = ($page - 1) * $size;
     return (array) $this->storage->findAll($offset, $size);
 }
 /**
  * @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.");
 }