コード例 #1
0
 /**
  * Add new timeslot
  * @Route("/edit/timeslot/add/{tournamentid}", name="_edit_timeslot_add")
  * @Template("ICupPublicSiteBundle:Edit:edittimeslot.html.twig")
  */
 public function addAction($tournamentid, Request $request)
 {
     /* @var $utilService Util */
     $utilService = $this->get('util');
     $returnUrl = $utilService->getReferer();
     /* @var $user User */
     $user = $utilService->getCurrentUser();
     /* @var $tournament Tournament */
     $tournament = $this->get('entity')->getTournamentById($tournamentid);
     $host = $tournament->getHost();
     $utilService->validateEditorAdminUser($user, $host);
     $timeslot = new Timeslot();
     $timeslot->setTournament($tournament);
     $form = $this->makeTimeslotForm($timeslot, 'add');
     $form->handleRequest($request);
     if ($form->get('cancel')->isClicked()) {
         return $this->redirect($returnUrl);
     }
     if ($this->checkForm($form, $timeslot)) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($timeslot);
         $em->flush();
         return $this->redirect($returnUrl);
     }
     return array('form' => $form->createView(), 'action' => 'add', 'timeslot' => $timeslot);
 }
コード例 #2
0
 public function makePlaygrounds(Tournament $tournament)
 {
     for ($s = 1; $s <= 2; $s++) {
         $site = new Site();
         $site->setName("Test site " . $s);
         $site->setTournament($tournament);
         for ($n = 1; $n <= 2; $n++) {
             $playground = new Playground();
             $playground->setName("Test playground " . $s . "-" . $n);
             $playground->setLocation("");
             $playground->setNo($n);
             $playground->setSite($site);
             $site->getPlaygrounds()->add($playground);
         }
         $tournament->getSites()->add($site);
         $this->em->persist($site);
     }
     $timeslot = new Timeslot();
     $timeslot->setName("Period AM");
     $timeslot->setTournament($tournament);
     $timeslot->setCapacity(2);
     $timeslot->setPenalty(true);
     $timeslot->setRestperiod(60);
     $tournament->getTimeslots()->add($timeslot);
     $this->addSchedules($tournament, $timeslot, date_create_from_format("j-n-Y G.i", "5-7-2015 9.00"), date_create_from_format("j-n-Y G.i", "5-7-2015 12.00"), false);
     $this->addSchedules($tournament, $timeslot, date_create_from_format("j-n-Y G.i", "6-7-2015 9.00"), date_create_from_format("j-n-Y G.i", "6-7-2015 12.00"), false);
     $this->addSchedules($tournament, $timeslot, date_create_from_format("j-n-Y G.i", "7-7-2015 9.00"), date_create_from_format("j-n-Y G.i", "7-7-2015 12.00"), false);
     $this->addSchedules($tournament, $timeslot, date_create_from_format("j-n-Y G.i", "8-7-2015 9.00"), date_create_from_format("j-n-Y G.i", "8-7-2015 12.00"), true);
     $this->em->persist($timeslot);
     $timeslot = new Timeslot();
     $timeslot->setName("Period PM");
     $timeslot->setTournament($tournament);
     $timeslot->setCapacity(1);
     $timeslot->setPenalty(false);
     $timeslot->setRestperiod(60);
     $tournament->getTimeslots()->add($timeslot);
     $this->addSchedules($tournament, $timeslot, date_create_from_format("j-n-Y G.i", "5-7-2015 13.00"), date_create_from_format("j-n-Y G.i", "5-7-2015 19.00"), false);
     $this->addSchedules($tournament, $timeslot, date_create_from_format("j-n-Y G.i", "6-7-2015 13.00"), date_create_from_format("j-n-Y G.i", "6-7-2015 19.00"), false);
     $this->addSchedules($tournament, $timeslot, date_create_from_format("j-n-Y G.i", "7-7-2015 13.00"), date_create_from_format("j-n-Y G.i", "7-7-2015 19.00"), false);
     $this->addSchedules($tournament, $timeslot, date_create_from_format("j-n-Y G.i", "8-7-2015 13.00"), date_create_from_format("j-n-Y G.i", "8-7-2015 22.00"), true);
     $this->em->persist($timeslot);
     $this->em->flush();
 }
コード例 #3
0
 private function importTimeslots(Tournament $source_tournament, Tournament $tournament)
 {
     $em = $this->getDoctrine()->getManager();
     $tsconversion = array();
     foreach ($source_tournament->getTimeslots() as $timeslot) {
         $new_timeslot = new Timeslot();
         $new_timeslot->setTournament($tournament);
         $new_timeslot->setName($timeslot->getName());
         $new_timeslot->setCapacity($timeslot->getCapacity());
         $new_timeslot->setPenalty($timeslot->getPenalty());
         $new_timeslot->setRestperiod($timeslot->getRestperiod());
         $em->persist($new_timeslot);
         $tsconversion[$timeslot->getId()] = $new_timeslot;
     }
     $em->flush();
     return $tsconversion;
 }