示例#1
0
 public function viewAction()
 {
     $id = $this->params()->fromRoute('id');
     $player = $this->playerRepository->find($id);
     $pointLogs = $this->pointLogPlayerRepository->getForPlayer($player);
     return array('player' => $player, 'logs' => $pointLogs);
 }
示例#2
0
 /**
  * Hydrate $object with the provided $data.
  *
  * @param array $data
  * @param \Application\Model\Entity\Match $match
  *
  * @return \Application\Model\Entity\Match
  */
 public function hydrate(array $data, $match)
 {
     $match->setGames($data['games']);
     if ($match instanceof DoubleMatch) {
         $match->setTeamOne($this->repository->find($data['teamOneAttack']), $this->repository->find($data['teamOneDefence']));
         $match->setTeamTwo($this->repository->find($data['teamTwoAttack']), $this->repository->find($data['teamTwoDefence']));
     }
     return $match;
 }
示例#3
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);
 }
示例#4
0
 public function setupTournamentAction()
 {
     $id = $this->params()->fromRoute('id');
     $tournament = $this->tournamentRepository->find($id);
     if (!$tournament instanceof \Application\Model\Entity\Tournament) {
         throw new \RuntimeException('Invalid tournament ID');
     }
     $form = $this->getAddPlayerForm($tournament);
     if ($this->request->isPost()) {
         $form->setData($this->request->getPost());
         if ($form->isValid()) {
             $playerId = $form->get('player')->getValue();
             $player = $this->playerRepository->find($playerId);
             $tournament->addPlayer($player);
             $this->tournamentRepository->persist($tournament);
             return $this->redirect()->toRoute('setup', array('id' => $tournament->getId()));
         }
     }
     return array('tournament' => $tournament, 'addPlayerForm' => $form);
 }