private function copyPlayground(Playground $source_playground, Playground $target_playground)
 {
     $em = $this->getDoctrine()->getManager();
     /* @var $attr PlaygroundAttribute */
     foreach ($source_playground->getPlaygroundAttributes() as $attr) {
         if ($this->get('logic')->getPlaygroundAttribute($target_playground->getId(), $attr->getDate(), $attr->getStart()) == null) {
             $target_attr = new PlaygroundAttribute();
             $target_attr->setPlayground($target_playground);
             $target_attr->setTimeslot($attr->getTimeslot());
             $target_attr->setDate($attr->getDate());
             $target_attr->setStart($attr->getStart());
             $target_attr->setEnd($attr->getEnd());
             $target_attr->setFinals($attr->getFinals());
             $em->persist($target_attr);
         }
     }
     $em->flush();
 }
 private function updatePAttr(PAttrForm $pattrForm, PlaygroundAttribute &$pattr)
 {
     $timeslotid = $pattrForm->getTimeslot();
     $pattr->setTimeslot($this->get('entity')->getTimeslotById($timeslotid));
     $dateformat = $this->get('translator')->trans('FORMAT.DATE');
     $matchdate = date_create_from_format($dateformat, $pattrForm->getDate());
     $pattr->setDate(Date::getDate($matchdate));
     $timeformat = $this->get('translator')->trans('FORMAT.TIME');
     $starttime = date_create_from_format($timeformat, $pattrForm->getStart());
     $pattr->setStart(Date::getTime($starttime));
     $endtime = date_create_from_format($timeformat, $pattrForm->getEnd());
     $pattr->setEnd(Date::getTime($endtime));
     $pattr->setFinals($pattrForm->isFinals());
 }
Esempio n. 3
0
 private function addSchedules(Tournament $tournament, Timeslot $timeslot, DateTime $start, DateTime $end, $final)
 {
     /* @var $site Site */
     foreach ($tournament->getSites() as $site) {
         /* @var $playground Playground */
         foreach ($site->getPlaygrounds() as $playground) {
             $pattr = new PlaygroundAttribute();
             $pattr->setTimeslot($timeslot);
             $pattr->setPlayground($playground);
             $pattr->setDate(Date::getDate($start));
             $pattr->setStart(Date::getTime($start));
             $pattr->setEnd(Date::getTime($end));
             $pattr->setFinals($final);
             $playground->getPlaygroundAttributes()->add($pattr);
             $timeslot->getPlaygroundattributes()->add($pattr);
         }
     }
 }
 private function importPAttrs(Playground $playground, Playground $new_playground, array $tsconversion, array $cconversion)
 {
     $em = $this->getDoctrine()->getManager();
     foreach ($playground->getPlaygroundAttributes() as $pattr) {
         $new_pattr = new PlaygroundAttribute();
         $new_pattr->setPlayground($new_playground);
         $new_pattr->setTimeslot($tsconversion[$pattr->getTimeslot()->getId()]);
         $new_pattr->setDate($pattr->getDate());
         $new_pattr->setStart($pattr->getStart());
         $new_pattr->setEnd($pattr->getEnd());
         $new_pattr->setFinals($pattr->getFinals());
         foreach ($pattr->getCategories() as $category) {
             $new_pattr->getCategories()->add($cconversion[$category->getId()]);
         }
         $em->persist($new_pattr);
     }
     $em->flush();
 }