public function load(ObjectManager $manager) { $listNames = array('RĂ©mi', 'Axel', 'Batman'); foreach ($listNames as $name) { $user = new User(); $user->setUsername($name); $user->setPassword($name); $manager->persist($user); } $manager->flush(); }
public function load(ObjectManager $em) { $passwordEncoder = $this->container->get('security.password_encoder'); $johnUser = new User(); $johnUser->setUsername('john_user'); $johnUser->setEmail('*****@*****.**'); #$johnUser->setPassword('kitten'); $encodedPassword = $passwordEncoder->encodePassword($johnUser, 'kitten'); $johnUser->setPassword($encodedPassword); $johnUser->setRoles(array('ROLE_USER')); $annaAdmin = new User(); $annaAdmin->setUsername('anna_admin'); $annaAdmin->setEmail('*****@*****.**'); #$annaAdmin->setPassword('kitten'); $encodedPassword = $passwordEncoder->encodePassword($annaAdmin, 'kitten'); $annaAdmin->setPassword($encodedPassword); $annaAdmin->setRoles(array('ROLE_ADMIN')); $annaAdmin->setIsActive(true); $em->persist($johnUser); $em->persist($annaAdmin); $em->flush(); }
/** * {@inheritDoc} */ public function setUsername($username) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsername', array($username)); return parent::setUsername($username); }