protected function getJsonView($data, \Request $request) { if (!$request->isVar('command')) { throw new \Exception('Unknown Ticket command'); } $json = array('success' => true); $command = $request->getVar('command'); switch ($command) { case 'list': $json = Factory::getList(Factory::pullGetString('singleId')); break; case 'checkUrl': $json = array('success' => Factory::checkURL(Factory::pullGetString('checkUrl'))); break; } $view = new \View\JsonView($json); return $view; }
/** * Returns a list of single ballots with included tickets. * * Tickets ARE REQUIRED. A ballot without tickets will be unset. * * @param type $electionId * @param type $addCandidates * @return array */ public static function getListWithTickets($electionId, $addCandidates = true, $randomize = ELECTION_RANDOMIZE_TICKETS) { $singleList = self::getList($electionId); if (empty($singleList)) { return array(); } foreach ($singleList as $key => &$value) { $tickets = null; if ($addCandidates) { $tickets = Ticket::getListWithCandidates($value['id'], $randomize); } else { $tickets = Ticket::getList($value['id'], $randomize); } if (empty($tickets)) { unset($singleList[$key]); } else { $value['tickets'] = $tickets; } } return $singleList; }