Example #1
0
 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;
 }
Example #2
0
 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);
 }