示例#1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $isVerbose = $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
     $sourceUsername = $input->getOption('source-user');
     if (!$sourceUsername) {
         $output->writeln("<error>--source-user is required</error>");
         die;
     }
     $targetUsername = $input->getOption('target-user') ?: $sourceUsername;
     $fromLocationResource = new LocationResource($this->sourceClient);
     $toObserveResource = new ObserveResource($this->client);
     $fromUserResource = new UserResource($this->sourceClient);
     $toUserResource = new UserResource($this->client);
     $sourceUser = $fromUserResource->getOneBy(['username' => $sourceUsername]);
     if (!$sourceUser) {
         $output->writeln("<error>Source user {$sourceUsername} not found</error>");
         die;
     }
     $targetUser = $toUserResource->getOneBy(['username' => $targetUsername]);
     if (!$targetUser) {
         $output->writeln("<error>Target user {$targetUsername} not found</error>");
         die;
     }
     die('Not yet implemented');
     // @todo
     $page = 0;
     $perPage = 10;
     $maxPages = 1;
     while ($page < $maxPages) {
         $result = $fromLocationResource->getList(++$page, $perPage, ['user_id' => $sourceUser['id']], [], [], ['details' => true]);
         var_dump($result['items']);
         die;
         $maxPages = $result['pages'];
         // if no items, return
         if (!count($result['items']) || !$result['total']) {
             break;
         }
         var_dump($result['items']);
         die;
         $locationsToPost = [];
         foreach ($result['items'] as $key => $location) {
             if ($isVerbose) {
                 $no = ($page - 1) * $perPage + $key + 1;
                 $output->writeln("{$no} - Reading location #{$location['id']}");
             }
             $locationsToPost[] = [];
         }
     }
 }
示例#2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $isVerbose = $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
     $username = $input->getOption('user');
     $date = $input->getOption('date');
     $output->writeln("Getting locations for {$date}");
     $userResource = new UserResource($this->sourceClient);
     $criteria = [];
     if ($username) {
         $user = $userResource->getOneBy(['username' => $username]);
         if (!$user) {
             throw new \Exception("User {$username} not found");
         }
         $criteria['user_id'] = $user['id'];
     }
     $locationResource = new LocationResource($this->sourceClient);
     $result = $locationResource->getList(1, 100, $criteria, null, null, ['start_date' => $date]);
     var_dump($result);
 }