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 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(); }