Example #1
0
 /**
  * @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);
 }
Example #2
0
 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);
     }
 }
Example #3
0
 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()));
 }
Example #4
0
 /**
  * @return array
  */
 public function dashboardAction()
 {
     return array('matches' => $this->matchRepository->getLastMatches(), 'tournaments' => $this->tournamentRepository->findAllActive());
 }