Esempio n. 1
0
 public function checkPairsInGroup($group, $categoryId, $pairs)
 {
     $inscriptionService = new InscriptionService();
     $inscriptionService->setManager($this->em);
     $inscirptions = array();
     foreach ($pairs as $pair) {
         $inscriptionEntity = $inscriptionService->getInscriptionsByPairAndCategory($pair, $categoryId);
         if ($inscriptionEntity instanceof Inscription) {
             if ($inscriptionEntity->getGroup()->getId() != $group->getId()) {
                 $inscriptionEntity->setGroup($group);
                 $this->em->persist($inscriptionEntity);
             }
         }
     }
     $this->em->flush();
 }
Esempio n. 2
0
 public function createDrawTournament($tournament, $params)
 {
     $categoryService = new CategoryService();
     $categoryService->setManager($this->em);
     $inscriptionService = new InscriptionService();
     $inscriptionService->setManager($this->em);
     $gamesForDraw = array();
     $saveChangesCorrect = true;
     if (!empty($params)) {
         foreach ($params as $categoryId => $category) {
             $categoryEntity = $categoryService->getCategory($categoryId);
             if (!is_null($categoryEntity)) {
                 $inscriptionsInCategory = array();
                 foreach ($category as $pairId) {
                     $inscriptionsInCategory[] = $inscriptionService->getInscriptionsByPairAndCategory($pairId, $categoryId);
                 }
                 $gamesForDraw[$categoryEntity->getName() . ';' . $categoryId] = $categoryService->createDrawForCategory($inscriptionsInCategory, $categoryId, $tournament->getId());
             } else {
                 $saveChangesCorrect = false;
             }
         }
     } else {
         $saveChangesCorrect = false;
     }
     if ($saveChangesCorrect) {
         $tournament->setStatus($this->statusService->getStatus('tournament', Literals::In_Finals_DateTournamentStatus));
         $this->em->persist($tournament);
         $this->em->flush();
         $result = array('result' => 'ok', 'message' => $gamesForDraw);
         return $result;
     } else {
         return $result = array('result' => 'fail', 'message' => Literals::TournamentChangesNotSaved);
     }
 }