public function load(ObjectManager $manager) { $data = $this->container->get('ilioscore.dataloader.learnerGroup')->getAll(); foreach ($data as $arr) { $entity = new LearnerGroup(); $entity->setId($arr['id']); $entity->setTitle($arr['title']); if (!empty($arr['location'])) { $entity->setLocation($arr['location']); } if (!empty($arr['parent'])) { $entity->setParent($this->getReference('learnerGroups' . $arr['parent'])); } $entity->setCohort($this->getReference('cohorts' . $arr['cohort'])); foreach ($arr['users'] as $id) { $entity->addUser($this->getReference('users' . $id)); } foreach ($arr['instructors'] as $id) { $entity->addInstructor($this->getReference('users' . $id)); } foreach ($arr['instructorGroups'] as $id) { $entity->addInstructorGroup($this->getReference('instructorGroups' . $id)); } $manager->persist($entity); $this->addReference('learnerGroups' . $arr['id'], $entity); } $manager->flush(); }