5 * Contains \Drupal\Console\Command\User\PasswordHashCommand.
8 namespace Drupal\Console\Command\User;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Input\InputArgument;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Console\Core\Command\Command;
14 use Drupal\Core\Password\PasswordInterface;
16 class PasswordHashCommand extends Command
19 * @var PasswordInterface
24 * PasswordHashCommand constructor.
26 * @param PasswordInterface $password
28 public function __construct(PasswordInterface $password)
30 $this->password = $password;
31 parent::__construct();
37 protected function configure()
40 ->setName('user:password:hash')
41 ->setDescription($this->trans('commands.user.password.hash.description'))
42 ->setHelp($this->trans('commands.user.password.hash.help'))
45 InputArgument::IS_ARRAY,
46 $this->trans('commands.user.password.hash.options.password')
48 ->setAliases(['uph']);
54 protected function interact(InputInterface $input, OutputInterface $output)
56 $password = $input->getArgument('password');
58 $password = $this->getIo()->ask(
59 $this->trans('commands.user.password.hash.questions.password')
62 $input->setArgument('password', [$password]);
69 protected function execute(InputInterface $input, OutputInterface $output)
71 $passwords = $input->getArgument('password');
74 $this->trans('commands.user.password.hash.messages.password'),
75 $this->trans('commands.user.password.hash.messages.hash'),
79 foreach ($passwords as $password) {
82 $this->password->hash($password),
86 $this->getIo()->table($tableHeader, $tableRows, 'compact');