예제 #1
0
 public function makeGroups(Tournament $tournament)
 {
     /* @var $category Category */
     foreach ($tournament->getCategories() as $category) {
         foreach (array('A', 'B', 'C') as $groupname) {
             $group = new Group();
             $group->setCategory($category);
             $group->setClassification(Group::$PRE);
             $group->setName($groupname);
             $category->getGroups()->add($group);
             $this->em->persist($group);
         }
     }
     $this->em->flush();
 }
 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;
 }