Example #1
0
 public function makeTournament()
 {
     $host = new Host();
     $host->setName("Test host");
     //        $host->setHostplan(new HostPlan());
     $tournament = new Tournament();
     $tournament->setName("Test tournament");
     $tournament->setDescription("Test edition of a tournament");
     $tournament->setEdition("2015");
     $tournament->setKey("TST2015");
     $tournament->setHost($host);
     $host->getTournaments()->add($tournament);
     $editor = new User();
     $editor->setUsername("test");
     $editor->setName("Test user");
     $editor->setPassword("");
     $editor->setEmail("*****@*****.**");
     $editor->addRole(User::ROLE_EDITOR_ADMIN);
     $editor->setEnabled(true);
     $editor->setHost($host);
     $host->getUsers()->add($editor);
     $this->em->persist($host);
     $this->em->flush();
     return $tournament;
 }
 private function importTournament(Tournament $source_tournament, Tournament $tournament)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $em->beginTransaction();
     try {
         $tournament->setKey(uniqid());
         $tournament->setEdition($source_tournament->getEdition());
         $tournament->setName($source_tournament->getName() . ' ' . $this->get('translator')->trans('FORM.TOURNAMENTIMPORT.COPY', array(), 'admin'));
         $tournament->setDescription($source_tournament->getDescription());
         $tournament->getOption()->setDrr($source_tournament->getOption()->isDrr());
         $tournament->getOption()->setStrategy($source_tournament->getOption()->getStrategy());
         $tournament->getOption()->setWpoints($source_tournament->getOption()->getWpoints());
         $tournament->getOption()->setTpoints($source_tournament->getOption()->getTpoints());
         $tournament->getOption()->setLpoints($source_tournament->getOption()->getLpoints());
         $tournament->getOption()->setDscore($source_tournament->getOption()->getDscore());
         $em->persist($tournament);
         $em->flush();
         $this->importSites($source_tournament, $tournament);
         $em->commit();
     } catch (Exception $e) {
         $em->rollBack();
         throw $e;
     }
 }