public static function getListWithCandidates($electionId) { $multiple = self::getList($electionId); if (empty($multiple)) { return array(); } foreach ($multiple as &$value) { $candidates = Candidate::getCandidateList($value['id']); $value['candidates'] = $candidates; } return $multiple; }
protected function getJsonView($data, \Request $request) { if (!$request->isVar('command')) { throw new \Exception('Unknown Candidate command'); } $json = array('success' => true); $command = $request->getVar('command'); switch ($command) { case 'ticketList': $json = Factory::getTicketList(Factory::pullGetInteger('ticketId')); break; case 'candidateList': $json = Factory::getCandidateList(Factory::pullGetInteger('multipleId')); break; } $view = new \View\JsonView($json); return $view; }
/** * Returns an array of tickets within a single chair ballot. * * Candidates ARE REQUIRED. A ticket without candidates is unset. * * @param type $singleId * @param type $random If true, the candidates are returned in a random order. * If false, the order is alphabetical. * @return array */ public static function getListWithCandidates($singleId, $random = true) { $tickets = self::getList($singleId, $random); if (empty($tickets)) { return array(); } foreach ($tickets as $key => &$value) { $candidates = null; $candidates = Candidate::getTicketList($value['id']); if (empty($candidates)) { unset($tickets[$key]); } else { $value['candidates'] = $candidates; } } return $tickets; }