diff --git a/src/Command/CreateUserCommand.php b/src/Command/CreateUserCommand.php new file mode 100644 index 0000000..f720917 --- /dev/null +++ b/src/Command/CreateUserCommand.php @@ -0,0 +1,51 @@ +addArgument('email', InputArgument::REQUIRED, 'User email address, used to login') + ->addArgument('password', InputArgument::REQUIRED, 'User password') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $email = $input->getArgument('email'); + $password = $input->getArgument('password'); + + $user = new User(); + $user->setEmail($email); + $user->setPassword($this->passwordHasher->hashPassword($user, $password)); + $this->em->persist($user); + $this->em->flush(); + + $io->success('User created.'); + return Command::SUCCESS; + } +}