コード例 #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);
 }
コード例 #2
0
 public function enrollTeam(Category $category, User $user, Club $club, $name, $division, $vacant = false)
 {
     $team = new Team();
     $team->setClub($club);
     $team->setName($name);
     $team->setColor('');
     $team->setDivision($division);
     $team->setVacant($vacant);
     $this->em->persist($team);
     $this->em->flush();
     $today = new DateTime();
     $enroll = new Enrollment();
     $enroll->setTeam($team);
     $enroll->setCategory($category);
     $enroll->setUser($user);
     $enroll->setDate(Date::getDate($today));
     $this->em->persist($enroll);
     $this->em->flush();
     return $enroll;
 }