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->setOwningSchool($this->getReference('schools' . $arr['owningSchool'])); $entity->setClerkshipType($this->getReference('courseClerkshipTypes' . $arr['clerkshipType'])); $manager->persist($entity); foreach ($arr['cohorts'] as $id) { $entity->addCohort($this->getReference('cohorts' . $id)); } foreach ($arr['directors'] as $id) { $entity->addDirector($this->getReference('users' . $id)); } foreach ($arr['disciplines'] as $id) { $entity->addDiscipline($this->getReference('disciplines' . $id)); } foreach ($arr['objectives'] as $id) { $entity->addObjective($this->getReference('objectives' . $id)); } $this->addReference('courses' . $arr['id'], $entity); } $manager->flush(); }
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->setExternalId($arr['externalId']); $entity->setLocked($arr['locked']); $entity->setArchived($arr['archived']); $entity->setPublishedAsTbd($arr['publishedAsTbd']); $entity->setPublished($arr['published']); $entity->setSchool($this->getReference('schools' . $arr['school'])); if (array_key_exists('ancestor', $arr)) { $entity->setAncestor($this->getReference('courses' . $arr['ancestor'])); } if (isset($arr['clerkshipType'])) { $entity->setClerkshipType($this->getReference('courseClerkshipTypes' . $arr['clerkshipType'])); } foreach ($arr['cohorts'] as $id) { $entity->addCohort($this->getReference('cohorts' . $id)); } foreach ($arr['directors'] as $id) { $entity->addDirector($this->getReference('users' . $id)); } foreach ($arr['administrators'] as $id) { $entity->addAdministrator($this->getReference('users' . $id)); } foreach ($arr['terms'] as $id) { $entity->addTerm($this->getReference('terms' . $id)); } foreach ($arr['objectives'] as $id) { $entity->addObjective($this->getReference('objectives' . $id)); } foreach ($arr['meshDescriptors'] as $id) { $entity->addMeshDescriptor($this->getReference('meshDescriptors' . $id)); } $manager->persist($entity); $this->addReference('courses' . $arr['id'], $entity); } $manager->flush(); }
/** * Gets a basic filled out course * * @return Course */ protected function createTestCourse() { $course = new Course(); $course->setId(10); $course->setTitle('test course'); $course->setLevel(1); $now = new DateTime(); $course->setYear((int) $now->format('Y')); $course->setStartDate(new DateTime('yesterday')); $course->setEndDate(new DateTime('tomorrow')); $course->setExternalId('I45'); $course->setLocked(true); $course->setArchived(true); $course->setPublished(true); $course->setPublishedAsTbd(true); return $course; }