Example #1
0
 public function load(ObjectManager $manager)
 {
     $data = $this->container->get('ilioscore.dataloader.session')->getAll();
     foreach ($data as $arr) {
         $entity = new Session();
         $entity->setId($arr['id']);
         $entity->setTitle($arr['title']);
         $entity->setSessionType($this->getReference('sessionTypes' . $arr['sessionType']));
         $entity->setCourse($this->getReference('courses' . $arr['course']));
         $entity->setPublishEvent($this->getReference('publishEvents' . $arr['publishEvent']));
         $entity->setIlmSessionFacet($this->getReference('ilmSessions' . $arr['ilmSessionFacet']));
         $related = array('disciplines' => 'addDiscipline', 'objectives' => 'addObjective');
         foreach ($related as $key => $method) {
             foreach ($arr[$key] as $id) {
                 $entity->{$method}($this->getReference($key . $id));
             }
         }
         $manager->persist($entity);
         $this->addReference('sessions' . $arr['id'], $entity);
     }
     $manager->flush();
 }