private function makeUpdMatchForm(MatchForm $matchForm, Match $match) { /* @var $qmh QMatchRelation */ $qmh = $this->get('match')->getQMatchRelationByMatch($match->getId(), false); $teamListA = $this->get('orderTeams')->sortGroup($qmh->getGroup()->getId()); $teamnamesA = array(); foreach ($teamListA as $team) { $teamnamesA[$team->id] = $team->name; } $teamA = $teamListA[$qmh->getRank() - 1]; $matchForm->setTeamA($teamA->id); /* @var $qma QMatchRelation */ $qma = $this->get('match')->getQMatchRelationByMatch($match->getId(), true); $teamListB = $this->get('orderTeams')->sortGroup($qma->getGroup()->getId()); $teamnamesB = array(); foreach ($teamListB as $team) { $teamnamesB[$team->id] = $team->name; } $teamB = $teamListB[$qma->getRank() - 1]; $matchForm->setTeamB($teamB->id); $show = true; $extshow = $show && !$this->get('match')->isMatchResultValid($matchForm->getId()); $formDef = $this->createFormBuilder($matchForm); $formDef->add('teamA', 'choice', array('label' => 'FORM.MATCH.HOME', 'choices' => $teamnamesA, 'empty_value' => 'FORM.MATCH.DEFAULT', 'required' => false, 'disabled' => !$extshow, 'translation_domain' => 'admin')); $formDef->add('teamB', 'choice', array('label' => 'FORM.MATCH.AWAY', 'choices' => $teamnamesB, 'empty_value' => 'FORM.MATCH.DEFAULT', 'required' => false, 'disabled' => !$extshow, 'translation_domain' => 'admin')); $formDef->add('cancel', 'submit', array('label' => 'FORM.MATCH.CANCEL.CHG', 'translation_domain' => 'admin', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times')); $formDef->add('save', 'submit', array('label' => 'FORM.MATCH.SUBMIT.CHG', 'translation_domain' => 'admin', 'icon' => 'fa fa-check')); return $formDef->getForm(); }
private function copyMatchForm(Match $match) { $matchForm = new MatchForm(); $matchForm->setId($match->getId()); $matchForm->setPid($match->getGroup()->getId()); $matchForm->setMatchno($match->getMatchno()); $matchdate = Date::getDateTime($match->getDate(), $match->getTime()); $dateformat = $this->get('translator')->trans('FORMAT.DATE'); $matchForm->setDate(date_format($matchdate, $dateformat)); $timeformat = $this->get('translator')->trans('FORMAT.TIME'); $matchForm->setTime(date_format($matchdate, $timeformat)); $matchForm->setPlayground($match->getPlayground()); /* @var $homeRel QMatchRelation */ $homeRel = $this->get('match')->getQMatchRelationByMatch($match->getId(), false); if ($homeRel != null) { $matchForm->setGroupA($homeRel->getGroup()->getId()); $matchForm->setRankA($homeRel->getRank()); } /* @var $awayRel QMatchRelation */ $awayRel = $this->get('match')->getQMatchRelationByMatch($match->getId(), true); if ($awayRel != null) { $matchForm->setGroupB($awayRel->getGroup()->getId()); $matchForm->setRankB($awayRel->getRank()); } return $matchForm; }
private function getDetails(Match $match, $away) { $detail = array(); $details = $this->get('match')->getMatchRelationDetails($match->getId(), $away); if ($details) { $detail['id'] = $details['id']; $detail['name'] = $this->get('logic')->getTeamName($details['team'], $details['division']); $detail['country'] = $details['country']; } /* @var $qrel QMatchRelation */ $qrel = $this->get('match')->getQMatchRelationByMatch($match->getId(), $away); if ($qrel) { $group = $qrel->getGroup(); if ($group->getClassification() > 0) { $groupname = $this->get('translator')->trans('GROUPCLASS.' . $group->getClassification(), array(), 'tournament'); } else { $groupname = $this->get('translator')->trans('GROUP', array(), 'tournament'); } $rankTxt = $this->get('translator')->transChoice('RANK', $qrel->getRank(), array('%rank%' => $qrel->getRank(), '%group%' => strtolower($groupname) . ' ' . $group->getName()), 'tournament'); if (!array_key_exists('id', $detail)) { $detail['id'] = -1; } $detail['rank'] = $rankTxt; $detail['rgrp'] = $group->getId(); } return count($detail) > 0 ? $detail : null; }