protected function getJsonView($data, \Request $request) { if (!$request->isVar('command')) { throw new \Exception('Unknown Election command'); } $json = array('success' => true); $command = $request->getVar('command'); switch ($command) { case 'list': $json = Factory::getList(); break; case 'getElection': $json = $this->getElection($request->getVar('electionId')); break; case 'getElectionTypes': echo Factory::getFilterTypes(); exit; break; case 'checkConflict': $json = Factory::checkForConflict(Factory::pullGetInteger('startDate'), Factory::pullGetInteger('endDate'), Factory::pullGetInteger('electionId')); break; case 'findVote': $json = Factory::getStudentVoteInformation(Factory::pullGetInteger('electionId'), Factory::pullGetInteger('searchFor')); break; } $view = new \View\JsonView($json); return $view; }