コード例 #1
0
ファイル: TournamentController.php プロジェクト: 0ida/fussi
 /**
  * @param League $tournament
  *
  * @return array
  */
 protected function handleLeague(League $tournament)
 {
     $year = $this->params()->fromRoute('year');
     $month = $this->params()->fromRoute('month');
     $leaguePeriod = new LeaguePeriod($tournament->getStart(), $year, $month);
     if ($leaguePeriod->isOutOfBounds()) {
         $this->getResponse()->setStatusCode(404);
         return;
     }
     $matches = $this->matchRepository->findForPeriod($tournament, $leaguePeriod);
     $players = $tournament->getPlayers();
     $activePlayers = $this->matchRepository->getActivePlayers($tournament, $leaguePeriod);
     if (!$leaguePeriod->inCurrentMonth()) {
         $players = $activePlayers;
     }
     $ranking = new Ranking($matches);
     $infoMaxPoints = (count($players) - 1) * 2;
     $infoMaxMatches = count($players) - 1;
     $tournamentPotential = $ranking->getPotential(count($players) - 1);
     $infoMaxPoints = $infoMaxPoints >= 0 ? $infoMaxPoints : 0;
     $infoMaxMatches = $infoMaxMatches >= 0 ? $infoMaxMatches : 0;
     $viewData = array('period' => $leaguePeriod, 'players' => $players, 'activePlayers' => $activePlayers, 'matches' => $matches, 'ranking' => $ranking, 'tournament' => $tournament, 'infoMaxPoints' => $infoMaxPoints, 'infoMaxMatches' => $infoMaxMatches, 'tournamentPotential' => $tournamentPotential);
     $viewModel = new ViewModel($viewData);
     $viewModel->setTemplate('application/tournament/show-league');
     return $viewModel;
 }
コード例 #2
0
ファイル: LeagueTest.php プロジェクト: 0ida/fussi
 public function testStartProperty()
 {
     $date = new \DateTime('1994-04-05');
     $this->tournament->setStart($date);
     $this->assertSame($date, $this->tournament->getStart());
 }