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(); }
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']); $entity->setCohort($this->getReference('cohorts' . $arr['cohort'])); $manager->persist($entity); $this->addReference('learnerGroups' . $arr['id'], $entity); } $manager->flush(); }
/** * @covers \Ilios\CoreBundle\Entity\LearnerGroup::getSchool */ public function testGetSchool() { $school = new School(); $program = new Program(); $program->setSchool($school); $programYear = new ProgramYear(); $programYear->setProgram($program); $cohort = new Cohort(); $cohort->setProgramYear($programYear); $learnerGroup = new LearnerGroup(); $learnerGroup->setCohort($cohort); $this->assertEquals($school, $learnerGroup->getSchool()); $program = new Program(); $programYear = new ProgramYear(); $programYear->setProgram($program); $cohort = new Cohort(); $cohort->setProgramYear($programYear); $learnerGroup = new LearnerGroup(); $learnerGroup->setCohort($cohort); $this->assertNull($learnerGroup->getSchool()); $programYear = new ProgramYear(); $cohort = new Cohort(); $cohort->setProgramYear($programYear); $learnerGroup = new LearnerGroup(); $learnerGroup->setCohort($cohort); $this->assertNull($learnerGroup->getSchool()); $cohort = new Cohort(); $learnerGroup = new LearnerGroup(); $learnerGroup->setCohort($cohort); $this->assertNull($learnerGroup->getSchool()); $learnerGroup = new LearnerGroup(); $this->assertNull($learnerGroup->getSchool()); }