private function getTeam($groupid, $teamRaw)
 {
     if (isset($teamRaw['rank'])) {
         $rankingGroup = $this->get('logic')->getGroup($groupid, $teamRaw['group']);
         if ($rankingGroup == null) {
             throw new ValidationException("BADGROUP", "group=" . $teamRaw['group']);
         }
         if (!is_numeric($teamRaw['rank']) || $teamRaw['rank'] < 1) {
             throw new ValidationException("BADRANK", "rank=" . $teamRaw['rank']);
         }
         $relation = new QMatchScheduleRelation();
         $relation->setRank($teamRaw['rank']);
         $relation->setGroup($rankingGroup);
     } else {
         $infoteam = null;
         $teamList = $this->get('logic')->getTeamByGroup($groupid, $teamRaw['name'], isset($teamRaw['division']) ? $teamRaw['division'] : '');
         if (count($teamList) == 1) {
             $infoteam = $teamList[0];
         }
         foreach ($teamList as $team) {
             if (isset($teamRaw['country']) && $team->country == $teamRaw['country']) {
                 $infoteam = $team;
                 break;
             }
         }
         if (!$infoteam) {
             throw new ValidationException("BADTEAM", "group=" . $groupid . " team=" . $teamRaw['name'] . (isset($teamRaw['division']) ? " '" . $teamRaw['division'] . "'" : "") . (isset($teamRaw['country']) ? " (" . $teamRaw['country'] . ")" : ""));
         }
         $relation = new MatchScheduleRelation();
         $relation->setTeam($this->get('entity')->getTeamById($infoteam->getId()));
     }
     return $relation;
 }
Example #2
0
 private function makeMatchSchedule(Tournament $tournament, MatchPlan $match)
 {
     // for QMatchPlan, group and team are undefined - use classification and litra instead
     if ($match instanceof QMatchPlan) {
         /* @var $match QMatchPlan */
         $ms = new QMatchSchedule();
         $ms->setTournament($tournament);
         $ms->setCategory($this->em->merge($match->getCategory()));
         $ms->setBranch('');
         $ms->setClassification($match->getClassification());
         $ms->setLitra($match->getLitra());
         $hr = new QMatchScheduleRelation();
         $hr->setBranch($match->getRelA()->getBranch());
         $hr->setClassification($match->getRelA()->getClassification());
         $hr->setLitra($match->getRelA()->getLitra());
         $hr->setRank($match->getRelA()->getRank());
         $hr->setAwayteam(false);
         $ms->addQMatchRelation($hr);
         $ar = new QMatchScheduleRelation();
         $ar->setBranch($match->getRelB()->getBranch());
         $ar->setClassification($match->getRelB()->getClassification());
         $ar->setLitra($match->getRelB()->getLitra());
         $ar->setRank($match->getRelB()->getRank());
         $ar->setAwayteam(true);
         $ms->addQMatchRelation($ar);
     } else {
         $ms = new MatchSchedule();
         $ms->setTournament($tournament);
         $ms->setGroup($this->em->merge($match->getGroup()));
         $hr = new MatchScheduleRelation();
         $hr->setTeam($this->em->merge($match->getTeamA()));
         $hr->setAwayteam(false);
         $ms->addMatchRelation($hr);
         $ar = new MatchScheduleRelation();
         $ar->setTeam($this->em->merge($match->getTeamB()));
         $ar->setAwayteam(true);
         $ms->addMatchRelation($ar);
     }
     return $ms;
 }