コード例 #1
0
 protected function addNewUser($username, $email, $password)
 {
     $user = new User();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $this->em->persist($user);
     return $user;
 }
コード例 #2
0
 public function thereIsUser($username, $email, $password, $role = 'ROLE_USER', $enabled = true)
 {
     $user = new User();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setEnabled($enabled);
     $user->setPlainPassword($password);
     if (null !== $role) {
         $user->addRole($role);
     }
     $this->getEntityManager()->persist($user);
     return $user;
 }