Пример #1
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  * @throws \RuntimeException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     /** @var EntityManager $em */
     $em = $this->getContainer()->get('doctrine')->getManager();
     $login = $input->getOption('login') !== null ? $input->getOption('login') : $dialog->ask($output, 'Login: '******'firstName') !== null ? $input->getOption('firstName') : $dialog->ask($output, 'First name: ');
     $lastName = $input->getOption('lastName') !== null ? $input->getOption('lastName') : $dialog->ask($output, 'Last name: ');
     $password = $input->getOption('password') !== null ? $input->getOption('password') : $dialog->ask($output, 'Password: '******'email') !== null ? $input->getOption('email') : $dialog->ask($output, 'Public e-mail: ');
     $user = new User();
     $user->setKeepActive(true);
     $user->setLogin($login);
     $user->setFirstName($firstName);
     $user->setLastName($lastName);
     $user->setFullName($user->getFirstName() . ' ' . $user->getLastName());
     $user->setPassword($this->getContainer()->get('etu.user.crypting')->encrypt($password));
     $user->setMail($email);
     $em->persist($user);
     $em->flush();
     $output->writeln("\nDone.\n");
 }