Example #1
0
 protected function getJsonView($data, \Request $request)
 {
     $json = array();
     $command = $request->getVar('command');
     $factory = new Factory();
     $lotteryFactory = new \tailgate\Factory\Lottery();
     switch ($command) {
         case 'list':
             $game = Factory::getCurrent();
             if ($game) {
                 if ($game->getLotteryRun()) {
                     $json['available_spots'] = count(\tailgate\Factory\Lottery::getAvailableSpots());
                     $lottery = new \tailgate\Factory\Lottery();
                     $json['winners'] = $lottery->getTotalWinners($game->getId());
                     $json['claimed'] = $lottery->totalSpotsClaimed($game->getId());
                 } else {
                     $json['available_spots'] = $lotteryFactory->totalAvailableSpots();
                 }
             }
             break;
         case 'getCurrent':
             $json = $factory->getCurrentAsArray();
             break;
         case 'getAvailableSpots':
             $json = array('available_spots' => $factory->totalAvailableSpots());
             break;
         case 'unixtime':
             $json['unixtime'] = strtotime(filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING));
             break;
         default:
             throw new \Exception('Unknown command');
     }
     $view = new \View\JsonView($json);
     return $view;
 }
Example #2
0
 protected function getJsonView($data, \Request $request)
 {
     $command = $request->getVar('command');
     $factory = new Factory();
     $json = array('success' => true);
     switch ($command) {
         case 'getAvailableSpots':
             $json = array('available_spots' => $factory->totalAvailableSpots());
             break;
         case 'submissionCount':
             $json = array('submissions' => $this->getTotalSubmissions());
             break;
         case 'getUnclaimedSpots':
             $json = Factory::getAvailableSpots(null, null, false, true);
             break;
         default:
             throw new \Exception('Bad command:' . $request->getVar('command'));
     }
     $view = new \View\JsonView($json);
     return $view;
 }
Example #3
0
 protected function getJsonView($data, \Request $request)
 {
     $command = $request->getVar('command');
     $factory = new Factory();
     switch ($command) {
         case 'get':
             $json = $this->getLottery();
             break;
         case 'getAvailableLots':
             $json = $factory->getAvailableLots();
             break;
         case 'getSpotInfo':
             $lottery_id = filter_input(INPUT_GET, 'lotteryId', FILTER_SANITIZE_NUMBER_INT);
             $json = $factory->getSpotByLotteryId($lottery_id);
             break;
         case 'spotChoice':
             $json = \tailgate\Factory\Lottery::getAvailableSpots();
             break;
     }
     $view = new \View\JsonView($json);
     return $view;
 }