/** * @param Tournament $tournament * @param $matchList * @param PlanningOptions $options * @return PlanningResults */ public function setupCriteria(Tournament $tournament, $matchList, PlanningOptions $options) { $result = new PlanningResults(); /* @var $timeslot Timeslot */ foreach ($tournament->getTimeslots()->toArray() as $timeslot) { /* @var $pattr PlaygroundAttribute */ foreach ($timeslot->getPlaygroundattributes()->toArray() as $pattr) { if ($pattr->getFinals() == $options->isFinals()) { $pa = new PA(); $pa->setPA($pattr); $pa->setId($pattr->getId()); $pa->setPlayground($pattr->getPlayground()); $pa->setTimeslot($pattr->getTimeslot()); $pa->setSchedule($pattr->getStartSchedule()); $categories = array(); foreach ($pattr->getCategories() as $category) { $categories[$category->getId()] = $category; } $pa->setCategories($categories); $pa->setMatchlist(array()); $result->addTimeslot($pa); } } } if ($options->isFinals()) { // Order the match plan by classification ascending usort($matchList, function (QMatchPlan $m1, QMatchPlan $m2) { return min(1, max(-1, $m1->getClassification() - $m2->getClassification())); }); } else { // Order the match plan by group ascending usort($matchList, function (MatchPlan $m1, MatchPlan $m2) { return min(1, max(-1, $m1->getGroup()->getId() - $m2->getGroup()->getId())); }); } foreach ($matchList as $match) { $result->appendUnresolved($match); } return $result; }
private function makeTimeslotTable(Tournament $tournament) { $ts = array(); $pattrs = array(); $tournament->getTimeslots()->forAll(function ($idx, Timeslot $timeslot) use(&$pattrs) { $pattrs = array_merge($pattrs, $timeslot->getPlaygroundattributes()->toArray()); return true; }); /* @var $pattr PlaygroundAttribute */ foreach ($pattrs as $pattr) { $pa = new PA(); $pa->setPA($pattr); $pa->setId($pattr->getId()); $pa->setPlayground($pattr->getPlayground()); $pa->setTimeslot($pattr->getTimeslot()); $pa->setSchedule($pattr->getStartSchedule()); $categories = array(); foreach ($pattr->getCategories() as $category) { $categories[$category->getId()] = $category; } $pa->setCategories($categories); $pa->setMatchlist(array()); $ts[$pattr->getId()] = $pa; } return $ts; }
private function makePAttrForm(PAttrForm $pattrForm, Tournament $tournament, $action) { $timeslots = array(); foreach ($tournament->getTimeslots() as $timeslot) { $timeslots[$timeslot->getId()] = $timeslot->getName(); } $formDef = $this->createFormBuilder($pattrForm); $formDef->add('timeslot', 'choice', array('label' => 'FORM.PLAYGROUNDATTR.TIMESLOT.PROMPT', 'help' => 'FORM.PLAYGROUNDATTR.TIMESLOT.HELP', 'choices' => $timeslots, 'empty_value' => 'FORM.PLAYGROUNDATTR.DEFAULT', 'required' => false, 'disabled' => $action == 'del', 'translation_domain' => 'admin')); $formDef->add('date', 'text', array('label' => 'FORM.PLAYGROUNDATTR.DATE.PROMPT', 'help' => 'FORM.PLAYGROUNDATTR.DATE.HELP', 'required' => false, 'disabled' => $action == 'del', 'translation_domain' => 'admin')); $formDef->add('start', 'text', array('label' => 'FORM.PLAYGROUNDATTR.START.PROMPT', 'help' => 'FORM.PLAYGROUNDATTR.START.HELP', 'required' => false, 'disabled' => $action == 'del', 'translation_domain' => 'admin')); $formDef->add('end', 'text', array('label' => 'FORM.PLAYGROUNDATTR.END.PROMPT', 'help' => 'FORM.PLAYGROUNDATTR.END.HELP', 'required' => false, 'disabled' => $action == 'del', 'translation_domain' => 'admin')); $formDef->add('finals', 'checkbox', array('label' => 'FORM.PLAYGROUNDATTR.FINALS.PROMPT', 'help' => 'FORM.PLAYGROUNDATTR.FINALS.HELP', 'required' => false, 'disabled' => $action == 'del', 'translation_domain' => 'admin')); $formDef->add('cancel', 'submit', array('label' => 'FORM.PLAYGROUNDATTR.CANCEL.' . strtoupper($action), 'translation_domain' => 'admin', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times')); $formDef->add('save', 'submit', array('label' => 'FORM.PLAYGROUNDATTR.SUBMIT.' . strtoupper($action), 'translation_domain' => 'admin', 'icon' => 'fa fa-check')); return $formDef->getForm(); }
private function importTimeslots(Tournament $source_tournament, Tournament $tournament) { $em = $this->getDoctrine()->getManager(); $tsconversion = array(); foreach ($source_tournament->getTimeslots() as $timeslot) { $new_timeslot = new Timeslot(); $new_timeslot->setTournament($tournament); $new_timeslot->setName($timeslot->getName()); $new_timeslot->setCapacity($timeslot->getCapacity()); $new_timeslot->setPenalty($timeslot->getPenalty()); $new_timeslot->setRestperiod($timeslot->getRestperiod()); $em->persist($new_timeslot); $tsconversion[$timeslot->getId()] = $new_timeslot; } $em->flush(); return $tsconversion; }