/** * {@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(); }
/** * 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(); }