public function loadFOSUser()
 {
     foreach ($this->loadRaw('User') as $key => $data) {
         $entity = new User();
         $entity->setEnabled(true);
         $entity->setFirstName($data['firstName']);
         $entity->setLastName($data['lastName']);
         $entity->setUsername($data['username']);
         $entity->setEmail($data['email']);
         $entity->setPlainPassword($data['plainPassword']);
         foreach ($data['roles'] as $role) {
             $entity->addRole($role);
         }
         $entity->setDateOfBirth(new \DateTime($data['dateOfBirth']));
         $this->addReference($key, $entity);
         $this->manager->persist($entity);
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $faker = \Faker\Factory::create();
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $this->setPassword($userAdmin, 'admin');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setName('The Admin');
     $userAdmin->setLastname('');
     $userAdmin->setRoles(['ROLE_ADMIN']);
     $userAdmin->setEnabled(true);
     $userAdmin->setImage('admin.png');
     $manager->persist($userAdmin);
     $user = new User();
     $user->setUsername('user');
     $this->setPassword($user, 'user');
     $user->setEmail('*****@*****.**');
     $user->setLastname('');
     $user->setName('The User');
     $user->setRoles(['ROLE_USER']);
     $user->setEnabled(true);
     $user->setImage('user.png');
     $manager->persist($user);
     for ($i = 0; $i < 9; $i++) {
         $user = new User();
         $user->setUsername($faker->userName);
         $this->setPassword($user, 'secret');
         $user->setEmail($faker->companyEmail);
         $user->setName($faker->firstName);
         $user->setLastname($faker->lastName);
         $user->setRoles(['ROLE_USER']);
         $user->setEnabled(true);
         $user->setImage('user.png');
         $manager->persist($user);
     }
     $manager->flush();
 }
 /**
  * {@inheritDoc}
  */
 public function __toString()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, '__toString', array());
     return parent::__toString();
 }