예제 #1
0
 public function load(ObjectManager $manager)
 {
     $data = $this->container->get('ilioscore.dataloader.user')->getAll();
     foreach ($data as $arr) {
         $entity = new User();
         $entity->setId($arr['id']);
         $entity->setFirstName($arr['firstName']);
         $entity->setLastName($arr['lastName']);
         $entity->setMiddleName($arr['middleName']);
         $entity->setEmail($arr['email']);
         $entity->setEnabled($arr['enabled']);
         $entity->setIcsFeedKey($arr['icsFeedKey']);
         $entity->setPhone($arr['phone']);
         foreach ($arr['roles'] as $id) {
             $entity->addRole($this->getReference('userRoles' . $id));
         }
         foreach ($arr['cohorts'] as $id) {
             $entity->addCohort($this->getReference('cohorts' . $id));
         }
         $entity->setSchool($this->getReference('schools' . $arr['school']));
         if (isset($arr['primaryCohort'])) {
             $entity->setPrimaryCohort($this->getReference('cohorts' . $arr['primaryCohort']));
         }
         $manager->persist($entity);
         $this->addReference('users' . $arr['id'], $entity);
     }
     $manager->flush();
 }