Exemplo n.º 1
0
 /**
  * Add new club
  * @Route("/admin/club/add", name="_edit_club_add")
  * @Template("ICupPublicSiteBundle:Edit:editclub.html.twig")
  */
 public function addAction(Request $request)
 {
     $returnUrl = $this->get('util')->getReferer();
     $country = $request->get('country');
     if ($country == null) {
         $country = $this->get('util')->getCountryByLocale($request->getLocale());
     }
     $club = new Club();
     // If country is a part of the request parameters - use it
     $club->setCountry($country);
     $form = $this->makeClubForm($club, 'add');
     $form->handleRequest($request);
     if ($form->get('cancel')->isClicked()) {
         return $this->redirect($returnUrl);
     }
     if ($this->checkForm($form, $club)) {
         $otherclub = $this->get('logic')->getClubByName($club->getName(), $club->getCountry());
         if ($otherclub != null) {
             $form->addError(new FormError($this->get('translator')->trans('FORM.CLUB.NAMEEXIST', array(), 'admin')));
         } else {
             $em = $this->getDoctrine()->getManager();
             $em->persist($club);
             $em->flush();
             return $this->redirect($returnUrl);
         }
     }
     return array('form' => $form->createView(), 'action' => 'add', 'club' => $club);
 }
 /**
  * Add new club for for selected tournament
  * - Editor version only -
  * @Route("/edit/club/new/{tournamentid}", name="_host_club_new")
  * @Template("ICupPublicSiteBundle:Host:new_club.html.twig")
  */
 public function hostNewClubAction($tournamentid, Request $request)
 {
     /* @var $utilService Util */
     $utilService = $this->get('util');
     /* @var $user User */
     $user = $utilService->getCurrentUser();
     /* @var $tournament Tournament */
     $tournament = $this->get('entity')->getTournamentById($tournamentid);
     $host = $tournament->getHost();
     $utilService->validateEditorAdminUser($user, $host);
     // Prepare default data for form
     $clubFormData = $this->getClubDefaults($request);
     $form = $this->makeClubForm($clubFormData);
     $form->handleRequest($request);
     if ($form->get('cancel')->isClicked()) {
         return $this->redirect($this->generateUrl('_host_list_clubs', array('tournamentid' => $tournamentid)));
     }
     if ($this->checkForm($form, $clubFormData)) {
         $club = $this->get('logic')->getClubByName($clubFormData->getName(), $clubFormData->getCountry());
         if ($club == null) {
             $club = new Club();
             $club->setName($clubFormData->getName());
             $club->setCountry($clubFormData->getCountry());
             $em = $this->getDoctrine()->getManager();
             $em->persist($club);
             $em->flush();
         }
         return $this->redirect($this->generateUrl('_club_enroll_list_admin', array('tournament' => $tournamentid, 'club' => $club->getId())));
     }
     return array('form' => $form->createView(), 'action' => 'add', 'user' => $user, 'tournament' => $tournament);
 }
Exemplo n.º 3
0
 public function makeTeams(Tournament $tournament)
 {
     $testclubs = array(array("YOSLIK TASHKENT", "UZB"), array("B. URDULIZ", "ESP"), array("ATHENS 2015", "GRC"), array("N.H.C. TERAMO", "ITA"), array("GLADSAXE HG", "DNK"), array("UKS SPARTACUS", "POL"), array("TSINGHUA UNIV.", "CHN"), array("E.C. PINHEIROS", "BRA"), array("ZAGLEBIE LUBIN", "POL"), array("ASD FLAVIONI", "ITA"), array("SALASPILS SS", "LVA"), array("JSG ECHAZ ERMS", "DEU"), array("BRASIL REAL", "BRA"), array("HC MELITA", "MLT"), array("POGON ZABRIZE", "POL"), array("HC DUNAV BELENE", "BGR"), array("DTJ POLANKA", "CZE"), array("XINZHUANG JHS", "CHN"), array("ESBF", "FRA"), array("FALK", "NOR"), array("C.C. ANSIAO", "PRT"), array("ETIEC MENDOZA", "ARG"), array("VIKINGUR", "ISL"));
     $clubs = array();
     foreach ($testclubs as $clubinfo) {
         $club = new Club();
         $club->setName($clubinfo[0]);
         $club->setCountry($clubinfo[1]);
         $this->em->persist($club);
         $clubs[] = $club;
     }
     /* @var $user User */
     $user = $tournament->getHost()->getEditors()->first();
     /* @var $category Category */
     foreach ($tournament->getCategories() as $category) {
         $clubDiv = array_shift($clubs);
         /* @var $group Group */
         foreach ($category->getGroupsClassified(Group::$PRE) as $group) {
             for ($n = 1; $n <= 5; $n++) {
                 /* @var $club Club */
                 $club = array_shift($clubs);
                 $this->addTeam($category, $group, $club, "", $user);
                 array_push($clubs, $club);
             }
             $this->addTeam($category, $group, $clubDiv, $group->getName(), $user);
         }
         array_push($clubs, $clubDiv);
     }
     $this->em->flush();
 }
Exemplo n.º 4
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;
 }
 private function commitImport($parseObj, User $user)
 {
     $em = $this->getDoctrine()->getManager();
     $category = $parseObj['category'];
     $team = $parseObj['teamA'];
     $name = $parseObj['team']['name'];
     $division = $parseObj['team']['division'];
     $country = $parseObj['team']['country'];
     if (!$team) {
         $club = $this->get('logic')->getClubByName($name, $country);
         if ($club == null) {
             $club = new Club();
             $club->setName($name);
             $club->setCountry($country);
             $em->persist($club);
             $em->flush();
         }
         $enroll = $this->get('logic')->enrollTeam($category, $user, $club, $name, $division);
         $team = $enroll->getTeam();
     }
     if (!$this->get('logic')->isTeamAssigned($category->getId(), $team->getId())) {
         $group = $parseObj['group'];
         $this->get('logic')->assignEnrolled($team->getId(), $group->getId());
     }
 }