コード例 #1
0
ファイル: LoadUserData.php プロジェクト: nfouka/jobbet_sf2.5
 /**
  * @param \Doctrine\Common\Persistence\ObjectManager $em
  */
 public function load(ObjectManager $em)
 {
     $user = new User();
     $user->setUsername('admin');
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $encodedPassword = $encoder->encodePassword('admin', $user->getSalt());
     $user->setPassword($encodedPassword);
     $em->persist($user);
     $em->flush();
 }
コード例 #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $username = $input->getArgument('username');
     $password = $input->getArgument('password');
     $em = $this->getContainer()->get('doctrine')->getManager();
     $user = new User();
     $user->setUsername($username);
     // encode the password
     $factory = $this->getContainer()->get('security.encoder_factory');
     $encoder = $factory->getEncoder($user);
     $encodedPassword = $encoder->encodePassword($password, $user->getSalt());
     $user->setPassword($encodedPassword);
     $em->persist($user);
     $em->flush();
     $output->writeln(sprintf('Added %s user with password %s', $username, $password));
 }
コード例 #3
0
ファイル: User.php プロジェクト: nfouka/jobbet_sf2.5
 public function equals(User $user)
 {
     return $user->getUsername() == $this->getUsername();
 }