예제 #1
0
 /**
  * @param Group $group
  * @param PlanningOptions $options
  * @return array
  */
 private function populateGroup(Group $group, PlanningOptions $options)
 {
     $matches = array();
     $teams = $group->getTeams();
     $check = array();
     /* @var $teamA Team */
     foreach ($teams as $teamA) {
         $idx = 0;
         /* @var $teamB Team */
         foreach ($teams as $teamB) {
             if ($teamA->getId() != $teamB->getId() && !isset($check[$teamB->getId()])) {
                 $switch = $idx % 2 == 0 || $options->isDoublematch();
                 $match = new MatchPlan();
                 $match->setTeamA($switch ? $teamA : $teamB);
                 $match->setTeamB($switch ? $teamB : $teamA);
                 $match->setFixed(false);
                 $matches[] = $match;
                 $idx++;
             }
         }
         if (!$options->isDoublematch()) {
             $check[$teamA->getId()] = $teamA;
         }
     }
     return $matches;
 }
 /**
  * Build the elimination pyramid top-down
  * Groups are expected to be populated in descending classification order:
  *     final, 3/4 final, semifinals, 1/4 finals, ...
  * @param $pyramid The elimination pyramid
  * @param $group The new group to attach to the pyramid
  * @param $matchList Matches for the new group to attach
  */
 private function buildPyramid(&$pyramid, Group $group, $matchList)
 {
     foreach ($matchList as &$match) {
         $match['group'] = $group;
         switch ($group->getClassification()) {
             case Group::$FINAL:
                 $pyramid['F'] = $match;
                 break;
             case Group::$BRONZE:
                 $pyramid['B'] = $match;
                 break;
             default:
                 $this->crawl($pyramid['F'], Group::$SEMIFINAL - $group->getClassification(), $match);
                 break;
         }
     }
 }
예제 #3
0
 private function addTeam(Category $category, Group $group, Club $club, $division, User $user)
 {
     $team = new Team();
     $team->setName($club->getName());
     $team->setColor($category->getName() . $group->getName() . ($group->getGroupOrder()->count() + 1));
     $team->setDivision($division);
     $team->setVacant(false);
     $team->setClub($club);
     $club->getTeams()->add($team);
     $this->em->persist($team);
     $grouporder = new GroupOrder();
     $grouporder->setGroup($group);
     $grouporder->setTeam($team);
     $team->getGroupOrder()->add($grouporder);
     $group->getGroupOrder()->add($grouporder);
     $this->em->persist($grouporder);
     $enrollment = new Enrollment();
     $enrollment->setTeam($team);
     $enrollment->setCategory($category);
     $enrollment->setDate(Date::getDate(new DateTime()));
     $enrollment->setUser($user);
     $team->getEnrollments()->add($enrollment);
     $category->getEnrollments()->add($enrollment);
     $user->getEnrollments()->add($enrollment);
     $this->em->persist($enrollment);
 }
예제 #4
0
 public function findTeamByGroup(Group $group, $name, $division, $country)
 {
     $qb = $this->em->createQuery("select t " . "from " . $this->entity->getRepositoryPath('GroupOrder') . " o, " . $this->entity->getRepositoryPath('Team') . " t, " . $this->entity->getRepositoryPath('Club') . " c " . "where o.group=:group and " . "o.team=t.id and " . "c.country=:country and " . "t.club=c.id and " . "t.name=:name and " . "t.division=:division");
     $qb->setParameter('group', $group->getId());
     $qb->setParameter('name', $name);
     $qb->setParameter('division', $division);
     $qb->setParameter('country', $country);
     return $qb->getOneOrNullResult();
 }
 private function importCategories(Tournament $source_tournament, Tournament $tournament)
 {
     $em = $this->getDoctrine()->getManager();
     $cconversion = array();
     /* @var $category Category */
     foreach ($source_tournament->getCategories() as $category) {
         $new_category = new Category();
         $new_category->setTournament($tournament);
         $new_category->setName($category->getName());
         $new_category->setGender($category->getGender());
         $new_category->setClassification($category->getClassification());
         $new_category->setAge($category->getAge());
         $new_category->setMatchtime($category->getMatchtime());
         $em->persist($new_category);
         $cconversion[$category->getId()] = $new_category;
         foreach ($category->getGroups() as $group) {
             $new_group = new Group();
             $new_group->setCategory($new_category);
             $new_group->setName($group->getName());
             $new_group->setClassification($group->getClassification());
             $em->persist($new_group);
         }
     }
     $em->flush();
     return $cconversion;
 }
예제 #6
0
 public function __toString()
 {
     return $this->classification . ":" . ($this->group ? $this->group->getName() : $this->litra) . $this->branch . "#" . $this->rank;
 }
예제 #7
0
 private function checkForm($form, Group $group)
 {
     if ($form->isValid()) {
         if ($group->getName() == null || trim($group->getName()) == '') {
             $form->addError(new FormError($this->get('translator')->trans('FORM.GROUP.NONAME', array(), 'admin')));
             return false;
         }
         if ($group->getClassification() === null) {
             $form->addError(new FormError($this->get('translator')->trans('FORM.GROUP.NOCLASSIFICATION', array(), 'admin')));
             return false;
         }
         return true;
     }
     return false;
 }