/** * Update tournament schedule with qualified teams * @param $tournamentid * @return array */ public function updateTournamentSchedule($tournamentid) { $groups = $this->map($this->logic->listGroupsByTournament($tournamentid)); $playgrounds = $this->map($this->logic->listPlaygroundsByTournament($tournamentid)); $settledGroups = array(); /* @var $group Group */ foreach ($groups as $group) { $settledGroups[$group->getId()] = $this->order->sortCompletedGroup($group->getId()); } $matches = array(); $matchList = $this->match->listOpenQMatchesByTournament($tournamentid); /* @var $qmatch QMatch */ foreach ($matchList as $qmatch) { $sortedGrpA = $settledGroups[$qmatch->getGroupA()]; $sortedGrpB = $settledGroups[$qmatch->getGroupB()]; if ($sortedGrpA && $sortedGrpB) { $match = new MatchPlan(); $match->setMatchno($qmatch->getMatchno()); $match->setDate($qmatch->getDate()); $match->setTime($qmatch->getTime()); $match->setGroup($groups[$qmatch->getPid()]); $match->setCategory($match->getGroup()->getCategory()); $match->setPlayground($playgrounds[$qmatch->getPlayground()]); $match->setTeamA($this->getTeam($sortedGrpA[$qmatch->getRankA()])); $match->setTeamB($this->getTeam($sortedGrpB[$qmatch->getRankB()])); $matches[] = array('Q' => $qmatch, 'M' => $match); } else { $matches[] = array('Q' => $qmatch, 'M' => null); } } return $matches; }
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; }