Exemplo n.º 1
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);
 }
 private function commitImport($parseObj)
 {
     /* @var $match Match */
     $match = $parseObj['match'];
     $goA = new GroupOrder();
     $goA->setTeam($parseObj['teamA']);
     $goA->setGroup($match->getGroup());
     $resultreqA = new MatchRelation();
     $resultreqA->setTeam($parseObj['teamA']);
     $resultreqA->setAwayteam(false);
     $resultreqA->setScorevalid(false);
     $resultreqA->setScore(0);
     $resultreqA->setPoints(0);
     $match->addMatchRelation($resultreqA);
     $goB = new GroupOrder();
     $goB->setTeam($parseObj['teamB']);
     $goB->setGroup($match->getGroup());
     $resultreqB = new MatchRelation();
     $resultreqB->setTeam($parseObj['teamB']);
     $resultreqB->setAwayteam(true);
     $resultreqB->setScorevalid(false);
     $resultreqB->setScore(0);
     $resultreqB->setPoints(0);
     $match->addMatchRelation($resultreqB);
     $em = $this->getDoctrine()->getManager();
     $em->persist($goA);
     $em->persist($goB);
     $em->persist($resultreqA);
     $em->persist($resultreqB);
 }
Exemplo n.º 3
0
 public function assignVacant($groupid, User $user)
 {
     /* @var $group Group */
     $group = $this->entity->getGroupById($groupid);
     $club = $this->getClubByName(BusinessLogic::$VACANT_CLUB_NAME, BusinessLogic::$VACANT_CLUB_COUNTRYCODE);
     if ($club == null) {
         $club = new Club();
         $club->setName(BusinessLogic::$VACANT_CLUB_NAME);
         $club->setCountry(BusinessLogic::$VACANT_CLUB_COUNTRYCODE);
         $this->em->persist($club);
         $this->em->flush();
     }
     $enrolled = $this->addEnrolled($group->getCategory(), $club, $user, true);
     $groupOrder = new GroupOrder();
     $groupOrder->setTeam($enrolled->getTeam());
     $groupOrder->setGroup($group);
     $this->em->persist($groupOrder);
     $this->em->flush();
     return $groupOrder;
 }