private function commitImport(Tournament $tournament, $matchList) { $em = $this->getDoctrine()->getManager(); foreach ($matchList as $match) { $matchrec = new MatchSchedule(); $matchrec->setTournament($tournament); $matchrec->setGroup($match['group']); $hr = $match['teamA']; $hr->setAwayteam(MatchSupport::$HOME); $matchrec->addMatchRelation($hr); $ar = $match['teamB']; $ar->setAwayteam(MatchSupport::$AWAY); $matchrec->addMatchRelation($ar); $matchPlan = new MatchSchedulePlan(); $matchPlan->setPlaygroundAttribute($match['pa']); $matchPlan->setMatchstart($match['time']); $matchPlan->setFixed(true); $matchrec->setPlan($matchPlan); $em->persist($matchrec); } $em->flush(); }
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; }