public function load(ObjectManager $manager) { $data = $this->container->get('ilioscore.dataloader.course')->getAll(); foreach ($data as $arr) { $entity = new Course(); $entity->setId($arr['id']); $entity->setTitle($arr['title']); $entity->setLevel($arr['level']); $entity->setYear($arr['year']); $entity->setStartDate(new \DateTime($arr['startDate'])); $entity->setEndDate(new \DateTime($arr['endDate'])); $entity->setDeleted($arr['deleted']); $entity->setExternalId($arr['externalId']); $entity->setLocked($arr['locked']); $entity->setArchived($arr['archived']); $entity->setSchool($this->getReference('schools' . $arr['school'])); $entity->setClerkshipType($this->getReference('courseClerkshipTypes' . $arr['clerkshipType'])); if (!empty($arr['publishEvent'])) { $entity->setPublishEvent($this->getReference('publishEvents' . $arr['publishEvent'])); } foreach ($arr['cohorts'] as $id) { $entity->addCohort($this->getReference('cohorts' . $id)); } foreach ($arr['directors'] as $id) { $entity->addDirector($this->getReference('users' . $id)); } foreach ($arr['topics'] as $id) { $entity->addTopic($this->getReference('topics' . $id)); } foreach ($arr['objectives'] as $id) { $entity->addObjective($this->getReference('objectives' . $id)); } $manager->persist($entity); $this->addReference('courses' . $arr['id'], $entity); } $manager->flush(); }