Beispiel #1
0
 /**
  * @param LeaguePeriod  $period
  * @param League    $tournament
  * @param SingleMatch[] $matches
  * @param Player        $player1
  * @param Player        $player2
  *
  * @return string
  */
 public function __invoke(LeaguePeriod $period, League $tournament, array $matches, Player $player1, Player $player2)
 {
     $allow = $period->inCurrentMonth();
     $out = '';
     if ($player1 != $player2) {
         $ok = false;
         foreach ($matches as $match) {
             $url = $this->getView()->url('match/edit', array('mid' => $match->getId()));
             if ($match->isPlayedBy($player1, $player2)) {
                 $title = $player1->getName() . " vs. " . $player2->getName();
                 $results = array();
                 $counter = 1;
                 foreach ($match->getGames() as $game) {
                     $results[] = "Game " . $counter . ": " . $game->getGoalsTeamOne() . ' / ' . $game->getGoalsTeamTwo();
                     $counter++;
                 }
                 $content = implode("<br>", $results);
                 if ($allow) {
                     $content .= "<br><br><a href='" . $url . "' class='btn btn-small'>Edit</a>";
                 }
                 $out .= '<span title="' . $title . '" data-content="' . $content . '" class="match btn result">';
                 $out .= $match->getScore();
                 $out .= '</span>';
                 $ok = true;
             }
         }
         if (!$ok && $allow) {
             $url = $this->getView()->url('match/new', array('tid' => $tournament->getId(), 'player1' => $player1->getId(), 'player2' => $player2->getId()));
             $out .= '<a href="' . $url . '" class="btn btn-small">Edit</a>';
         }
     }
     return $out;
 }
Beispiel #2
0
 public function testIdProperty()
 {
     $this->tournament->setId(1);
     $this->assertEquals(1, $this->tournament->getId());
 }
Beispiel #3
0
 /**
  * @param League $tournament
  * @param DateTime   $date
  *
  * @return string
  */
 protected function getUrl(League $tournament, DateTime $date)
 {
     return $this->view->url('tournament/show', array('id' => $tournament->getId(), 'year' => $date->format('Y'), 'month' => $date->format('m')));
 }