/**
  * Add a Pool to the Phase
  *
  * @Route("/{id}/new")
  * @param Phase $phase
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function newAction(Phase $phase)
 {
     $pool = new Pool();
     $pool->setName("Groupe " . (count($phase->getPools()) + 1));
     $phase->addPool($pool);
     $em = $this->getDoctrine()->getManager();
     $em->flush();
     return $this->redirect($this->generateUrl('abienvenu_kyjoukan_phase_index', ['slug_event' => $phase->getEvent()->getSlug(), 'slug' => $phase->getSlug()]) . "#pools");
 }
Exemple #2
0
 public function checkPhaseTeams(Phase $phase)
 {
     $errors = [];
     if (count($phase->getTeams())) {
         foreach ($phase->getEvent()->getTeams() as $team) {
             if (!$phase->hasTeam($team)) {
                 $errors[] = "L'équipe {$team->getName()} est exclue de cette phase";
             }
         }
     } else {
         $errors[] = "Aucune équipe n'est chargée dans cette phase. Utilisez le bouton \"Chargez les équipes de l'évènement\" pour recopier toutes les équipes de l'évènement dans cette phase";
     }
     return $errors;
 }
 /**
  * Creates a new Phase entity.
  *
  * @Route("/new_phase")
  * @param Request $request
  * @param Event $event
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function newPhaseAction(Request $request, Event $event)
 {
     $phase = new Phase();
     $phase->setStartDateTime(new \DateTime());
     $form = $this->createForm(new PhaseType($event), $phase);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $event->addPhase($phase);
         $em = $this->getDoctrine()->getManager();
         $em->flush();
         return $this->redirectToRoute('abienvenu_kyjoukan_event_index', ['slug' => $event->getSlug()]);
     }
     return $this->render('KyjoukanBundle:Event:new_phase.html.twig', ['event' => $event, 'form' => $form->createView()]);
 }
Exemple #4
0
 public function load(ObjectManager $manager)
 {
     // Event
     $event = new Event();
     $event->setName("Exemple de tournoi");
     $manager->persist($event);
     // Teams
     $teams = ["Les incorruptibles", "Boit-sans-soif", "Les intouchables", "Oclomosimanapa", "Chauds les marrons, chaud!", "Nevguen", "Chanteloup Badminton", "C'est sur la ligne", "972", "Pathinacé", "ONSPJ", "La prévière", "Kikonféla", "ZEbet", "Gibon", "Sardines", "Les cressonnettes", "Loulou coptères"];
     foreach ($teams as $teamName) {
         $team = new Team();
         $team->setName($teamName);
         $event->addTeam($team);
     }
     // Grounds
     $grounds = ["A", "B", "C"];
     foreach ($grounds as $groundName) {
         $ground = new Ground();
         $ground->setName($groundName);
         $event->addGround($ground);
     }
     // Phase
     $phase = new Phase();
     $phase->setName("Poules phase 1");
     $phase->setRule(Rule::ROUNDROBIN);
     $phase->setStartDateTime(new \DateTime());
     $phase->setRoundDuration(12 * 60);
     $event->addPhase($phase);
     // Pools
     $colors = [1 => "green", "red", "blue", "darkorange"];
     for ($i = 1; $i <= 4; $i++) {
         $pool = new Pool();
         $pool->setName("Pool {$i}");
         $pool->setColor($colors[$i]);
         $phase->addPool($pool);
     }
     $manager->flush();
 }
 /**
  * @Route("/ranking")
  * @param Phase $phase
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function rankingAction(Phase $phase)
 {
     $rankings = [];
     foreach ($phase->getPools() as $pool) {
         $index = 0;
         $key = $pool->getName();
         while (array_key_exists($key, $rankings)) {
             $index++;
             $key = "{$pool->getName()}_{$index}";
         }
         $rankings[$key] = $this->get('kyjoukan.ranker')->getPoolRanks($pool);
     }
     return $this->render("KyjoukanBundle:Phase:ranking.html.twig", ['rankings' => $rankings]);
 }
Exemple #6
0
 /**
  * Add phases
  *
  * @param Phase $phase
  * @return Event
  */
 public function addPhase(Phase $phase)
 {
     $this->phases[] = $phase;
     $phase->setEvent($this);
     return $this;
 }
 public function removeTeamFromPhase(Phase $phase, Team $team)
 {
     $isClear = true;
     foreach ($phase->getPools() as $pool) {
         $isClear &= $this->removeTeamFromPool($pool, $team);
     }
     if ($isClear) {
         $phase->removeTeam($team);
     }
     $this->em->flush();
     return $isClear;
 }