private function makeResultForm(ResultForm $resultForm) { /* @var $utilService Util */ $utilService = $this->get('util'); /* @var $user User */ $user = $utilService->getCurrentUser(); $tournamentKey = $this->get('util')->getTournamentKey(); if ($tournamentKey != '_') { $tournament = $this->get('logic')->getTournamentByKey($tournamentKey); if ($tournament != null) { $resultForm->setTournament($tournament->getId()); } } if ($user->isEditor()) { $tournaments = $user->getHost()->getTournaments(); } else { $tournaments = $this->get('logic')->listAvailableTournaments(); } $tournamentList = array(); foreach ($tournaments as $tmnt) { $tournamentList[$tmnt->getId()] = $tmnt->getName(); } $formDef = $this->createFormBuilder($resultForm); $formDef->add('tournament', 'choice', array('label' => 'FORM.CHANGEMATCH.TOURNAMENT', 'choices' => $tournamentList, 'empty_value' => false, 'required' => false, 'icon' => 'fa fa-lg fa-university', 'translation_domain' => 'admin')); $formDef->add('matchno', 'text', array('label' => 'FORM.CHANGEMATCH.MATCHNO', 'required' => false, 'help' => 'FORM.CHANGEMATCH.HELP.MATCHNO', 'icon' => 'fa fa-lg fa-calendar', 'translation_domain' => 'admin')); $formDef->add('cancel', 'submit', array('label' => 'FORM.CHANGEMATCH.CANCEL', 'translation_domain' => 'admin', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times')); $formDef->add('save', 'submit', array('label' => 'FORM.CHANGEMATCH.SUBMIT', 'translation_domain' => 'admin', 'icon' => 'fa fa-check')); return $formDef->getForm(); }
private function makeResultForm(ResultForm $resultForm) { $tournamentKey = $this->get('util')->getTournamentKey(); if ($tournamentKey != '_') { $tournament = $this->get('logic')->getTournamentByKey($tournamentKey); if ($tournament != null) { $resultForm->setTournament($tournament->getId()); } } $resultForm->setEvent(ResultForm::$EVENT_MATCH_PLAYED); $tournaments = $this->get('logic')->listAvailableTournaments(); $tournamentList = array(); $today = new DateTime(); foreach ($tournaments as $tmnt) { $stat = $this->get('tmnt')->getTournamentStatus($tmnt->getId(), $today); if ($stat == TournamentSupport::$TMNT_GOING) { $tournamentList[$tmnt->getId()] = $tmnt->getName(); } } $eventList = array(ResultForm::$EVENT_MATCH_PLAYED => 'MP', ResultForm::$EVENT_HOME_DISQ => 'HD', ResultForm::$EVENT_AWAY_DISQ => 'AD', ResultForm::$EVENT_NOT_PLAYED => 'NP'); foreach ($eventList as $event => $id) { $eventList[$event] = $this->get('translator')->trans('FORM.RESULTREPORT.EVENTTYPE.' . $id, array(), 'tournament'); } $formDef = $this->createFormBuilder($resultForm); $formDef->add('tournament', 'choice', array('label' => 'FORM.RESULTREPORT.TOURNAMENT', 'choices' => $tournamentList, 'empty_value' => false, 'required' => false, 'icon' => 'fa fa-lg fa-university', 'translation_domain' => 'tournament')); $formDef->add('matchno', 'text', array('label' => 'FORM.RESULTREPORT.MATCHNO', 'required' => false, 'help' => 'FORM.RESULTREPORT.HELP.MATCHNO', 'icon' => 'fa fa-lg fa-calendar', 'translation_domain' => 'tournament')); $formDef->add('scoreA', 'text', array('label' => 'FORM.RESULTREPORT.HOME', 'required' => false, 'help' => 'FORM.RESULTREPORT.HELP.HOME', 'icon' => 'fa fa-lg fa-home', 'translation_domain' => 'tournament')); $formDef->add('scoreB', 'text', array('label' => 'FORM.RESULTREPORT.AWAY', 'required' => false, 'help' => 'FORM.RESULTREPORT.HELP.AWAY', 'icon' => 'fa fa-lg fa-picture-o', 'translation_domain' => 'tournament')); $formDef->add('event', 'choice', array('label' => 'FORM.RESULTREPORT.EVENT', 'choices' => $eventList, 'empty_value' => false, 'required' => false, 'icon' => 'fa fa-lg fa-bolt', 'translation_domain' => 'tournament')); $formDef->add('cancel', 'submit', array('label' => 'FORM.RESULTREPORT.CANCEL', 'translation_domain' => 'tournament', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times')); $formDef->add('save', 'submit', array('label' => 'FORM.RESULTREPORT.SUBMIT', 'translation_domain' => 'tournament', 'icon' => 'fa fa-check')); return $formDef->getForm(); }