/** * @return ViewModel */ public function newAction() { $tournamentId = $this->params()->fromRoute('tid'); $tournament = $this->tournamentRepository->find($tournamentId); $player1Id = $this->params()->fromRoute('player1'); $player2Id = $this->params()->fromRoute('player2'); $player1 = $player1Id == null ? null : $this->playerRepository->find($player1Id); $player2 = $player2Id == null ? null : $this->playerRepository->find($player2Id); $match = $this->matchRepository->getNew($tournament, $player1, $player2); return $this->handleForm($match); }
public function showAction() { $id = $this->params()->fromRoute('id'); /** @var $tournament \Application\Model\Entity\League */ $tournament = $this->tournamentRepository->find($id); if ($tournament instanceof League) { return $this->handleLeague($tournament); } elseif ($tournament instanceof Tournament) { return $this->handleTournament($tournament); } }
public function startTournamentAction() { $id = $this->params()->fromRoute('id'); /** @var Tournament $tournament */ $tournament = $this->tournamentRepository->find($id); $teamGenerator = new \Application\Model\TeamGenerator(); $teams = $teamGenerator->generateTeams($tournament->getPlayers()); $plan = new \Application\Model\TournamentPlan\SingleElimination(); $rounds = $plan->init($teams); $tournament->init($teams, $rounds); $this->tournamentRepository->persist($tournament); return $this->redirect()->toRoute('tournament/show', array('id' => $tournament->getId())); }