Пример #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->setAttireRequired($arr['attireRequired']);
         $entity->setEquipmentRequired($arr['equipmentRequired']);
         $entity->setSupplemental($arr['supplemental']);
         $entity->setPublishedAsTbd($arr['publishedAsTbd']);
         $entity->setPublished($arr['published']);
         if (!empty($arr['sessionType'])) {
             $entity->setSessionType($this->getReference('sessionTypes' . $arr['sessionType']));
         }
         if (!empty($arr['course'])) {
             $entity->setCourse($this->getReference('courses' . $arr['course']));
         }
         $related = array('terms' => 'addTerm', 'objectives' => 'addObjective', 'meshDescriptors' => 'addMeshDescriptor');
         foreach ($related as $key => $method) {
             foreach ($arr[$key] as $id) {
                 $entity->{$method}($this->getReference($key . $id));
             }
         }
         foreach ($arr['administrators'] as $id) {
             $entity->addAdministrator($this->getReference('users' . $id));
         }
         $manager->persist($entity);
         $this->addReference('sessions' . $arr['id'], $entity);
     }
     $manager->flush();
 }