コード例 #1
0
ファイル: Match.php プロジェクト: bathan/fumbol_api
 private static function createFromDb($resource)
 {
     if (!is_null($resource)) {
         $match = new Match();
         $match->setMatchId($resource["match_id"]);
         $match->setMatchDateTime($resource["match_date_time"]);
         $match->setVenueId($resource["venue_id"]);
         $match->setPlayerCount($resource["player_count"]);
         $match->setWinningTeamId($resource["winning_team_id"]);
         $match->setTied($resource["tied"]);
         $match->setCreatedDate($resource["created_date"]);
         $match->setStatus($resource["status"]);
         return $match;
     }
     return null;
 }
コード例 #2
0
ファイル: MatchResource.php プロジェクト: bathan/fumbol_api
 private function buildMatchAndTeamsResponse(Match $match)
 {
     if (is_null($this->match_logic)) {
         $this->match_logic = new MatchLogic();
     }
     $match_id = $match->getMatchId();
     //-- Build Response. Get current Match and check if we have teams
     $current_teams = $this->match_logic->getMatchTeams($match_id);
     $current_match = $match->toArray();
     MatchUtilities::addMoreInfoToMatch($current_match);
     $api_response = ["match" => $current_match];
     //-- Fetch Players In teams Again from DB TODO:: Maybe we can skip this db query with what we have in memory
     $all_players = $this->match_logic->getAllMatchPlayers($match_id);
     $players_in_teams = Utilities::getPlayersInTeams($all_players);
     if (count($current_teams) > 0) {
         foreach ($current_teams as $team) {
             $match_team_id = intval($team['match_team_id']);
             $api_response["teams"][$match_team_id] = array_merge($team, ["players" => $players_in_teams[$match_team_id]]);
         }
     } else {
         $api_response["players"] = $all_players;
     }
     return $api_response;
 }
コード例 #3
0
ファイル: MatchLogic.php プロジェクト: bathan/fumbol_api
 public function sendCurrentMatchEmail(Match $match)
 {
     $match_players = $this->getAllMatchPlayers($match->getMatchId());
     $match_info = $match->toArray();
     MatchUtilities::addMoreInfoToMatch($match_info);
     $render_data = [];
     $render_data["match_day"] = Utilities::SpanishDate(strtotime($match_info["match_date_time"]));
     $render_data["venue_name"] = $match_info["venue"]["venue_name"];
     foreach ($match_players as $mp) {
         $render_data["players"][] = ["row_id" => $mp["row_id"], "nickname" => $mp["nickname"]];
     }
     $me = new \Mustache_Engine();
     $email_body = $me->render(file_get_contents(_APP_PATH . '/email_templates/convocatoria.html'), $render_data);
 }