예제 #1
0
파일: LoadUser.php 프로젝트: Raphy/AfterEpi
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $records = array(array('defrei_r', 'Raphael', 'Defreitas', array('ROLE_SUPER_ADMIN')));
     foreach ($records as $record) {
         $user = new User();
         $user->setLogin($record[0]);
         $user->setFirstname($record[1]);
         $user->setLastname($record[2]);
         $user->setRoles($record[3]);
         $manager->persist($user);
     }
     $manager->flush();
 }
예제 #2
0
 /**
  * Loads the user for the given username.
  *
  * This method must throw UsernameNotFoundException if the user is not
  * found.
  *
  * @param string $username The username
  *
  * @return UserInterface
  *
  * @see UsernameNotFoundException
  *
  * @throws UsernameNotFoundException if the user is not found
  *
  */
 public function loadUserByUsername($username)
 {
     if (empty($username)) {
         throw new UsernameNotFoundException();
     }
     if ($user = $this->findUserBy(array('login' => $username))) {
         return $user;
     }
     $user = new User();
     $user->setLogin($username);
     /*$this->em->persist($user);
       $this->em->flush();*/
     return $user;
     //throw new UsernameNotFoundException();
 }