Exemplo n.º 1
0
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $rm = $this->container->get('core_rest.resource_manager');
     //On récupère les groupes "utilisateurs"
     //$adminGroup = $this->getReference('admin-group');
     //$individualGroup = $this->getReference('individual-group');
     //$agencyGroup = $this->getReference('agency-group');
     //$builderGroup = $this->getReference('builder-group');
     //$developerGroup = $this->getReference('developer-group');
     //$instigatorGroup = $this->getReference('instigator-group');
     //On crée des nouveaux utilisateurs
     $userAdmin = new User();
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setFirstName("Michel");
     $userAdmin->setLastName("Admin");
     $userAdmin->setPlainPassword('admin');
     $particulier = new User();
     $particulier->setEmail('*****@*****.**');
     $particulier->setFirstName("Josette");
     $particulier->setLastName("Salle");
     $particulier->setPlainPassword("particulier");
     //On affecte les groupes aux utilisateurs
     //$userAdmin->addGroup($adminGroup);
     //$particulier->addGroup($individualGroup);
     //UserBundle
     $userAdmin->addRole('ROLE_NOTIFICATION_DELETE');
     $userAdmin->addRole('ROLE_NOTIFICATION_UPDATE');
     $rm->create($userAdmin);
     $this->addReference('userAdmin', $userAdmin);
 }
Exemplo n.º 2
0
 public function forceRegister($email, $username = null, $password = null)
 {
     if (!$username) {
         $username = $email;
     }
     if (!$password) {
         $password = $this->builder->randomPassword();
     }
     $user = new User();
     $user->setEmail($email);
     $user->setUsername($username);
     $user->setPlainPassword($password);
     $user->setPassword($this->encoder->encodePassword($user, $user->getPlainPassword()));
     $user->setLocale($this->params['locale']);
     $user->setActive(User::ACTIVE);
     $this->em->persist($user);
     $this->em->flush();
     return $user;
 }