示例#1
0
 public function getGameByGroupAction($idGroup)
 {
     $this->gameService->setManager($this->getDoctrine()->getManager());
     $games = $this->gameService->getGamesByGroup($idGroup);
     $groupService = new GroupService();
     $groupService->setManager($this->getDoctrine()->getManager());
     $group = $groupService->getGroup($idGroup);
     if (!$group instanceof GroupCategory) {
         return $this->util->setResponse(400, Literals::GroupNotFound);
     } else {
         $dataToSend = json_encode(array('game' => $games));
         return $this->util->setJsonResponse(200, $dataToSend);
     }
 }
示例#2
0
 private function setGameSave($game, $params)
 {
     $game->setDescription(!empty($params['description']) ? $params['description'] : '');
     if (!empty($params['category'])) {
         if (is_int($params['category'])) {
             $categoryService = new CategoryService();
             $categoryService->setManager($this->em);
             $cat = $categoryService->getCategory($params['category']);
             $game->setCategory($cat);
         } else {
             $game->setCategory($params['category']);
         }
     } else {
         $game->setCategory(null);
     }
     if (!empty($params['tournament'])) {
         if (is_int($params['tournament'])) {
             $tournamentService = new TournamentService();
             $tournamentService->setManager($this->em);
             $tournament = $tournamentService->getTournament($params['tournament']);
             $game->setTournament($tournament);
         } else {
             $game->setTournament($params['tournament']);
         }
     } else {
         $game->setTournament(null);
     }
     if (!empty($params['group'])) {
         if (is_int($params['group'])) {
             $groupService = new GroupService();
             $groupService->setManager($this->em);
             $group = $groupService->getGroup($params['group']);
             $game->setGroup($group);
         } else {
             $game->setGroup($params['group']);
         }
     } else {
         $game->setGroup(null);
     }
     $game->setPair1(!empty($params['pair1']) ? $params['pair1'] : null);
     $game->setPair2(!empty($params['pair2']) ? $params['pair2'] : null);
     $game->setScore(!empty($params['score']) ? $params['score'] : '');
     $game->setStatus($this->statusService->getStatus('game', Literals::CreatedGameStatus));
     $game->setStartDate(!empty($params['startDate']) ? $params['startDate'] : null);
     $game->setEndDate(!empty($params['endDate']) ? $params['endDate'] : null);
     $game->setTrack(!empty($params['track']) ? $params['track'] : '');
     $game->setBgColor(!empty($params['bgColor']) ? $params['bgColor'] : '');
     $game->setIsDrawGame(!empty($params['isDrawGame']) ? $params['isDrawGame'] : false);
     return $game;
 }