예제 #1
0
 /**
  * @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 프로젝트: abclaur/jobeet
 public function equals(User $user)
 {
     return $user->getUsername() == $this->getUsername();
 }