X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FUser%2FPasswordHashCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FUser%2FPasswordHashCommand.php;h=795e005adacc6081c05557752dccaefabbe40d3a;hp=208fe98ae03eae870923a4f795dbcbafecdded98;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console/src/Command/User/PasswordHashCommand.php b/vendor/drupal/console/src/Command/User/PasswordHashCommand.php index 208fe98ae..795e005ad 100644 --- a/vendor/drupal/console/src/Command/User/PasswordHashCommand.php +++ b/vendor/drupal/console/src/Command/User/PasswordHashCommand.php @@ -10,17 +10,11 @@ namespace Drupal\Console\Command\User; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Core\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Password\PasswordInterface; -use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Core\Style\DrupalStyle; class PasswordHashCommand extends Command { - use CommandTrait; - use ConfirmationTrait; - /** * @var PasswordInterface */ @@ -46,16 +40,34 @@ class PasswordHashCommand extends Command ->setName('user:password:hash') ->setDescription($this->trans('commands.user.password.hash.description')) ->setHelp($this->trans('commands.user.password.hash.help')) - ->addArgument('password', InputArgument::IS_ARRAY, $this->trans('commands.user.password.hash.options.password')); + ->addArgument( + 'password', + InputArgument::IS_ARRAY, + $this->trans('commands.user.password.hash.options.password') + ) + ->setAliases(['uph']); } /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function interact(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); + $password = $input->getArgument('password'); + if (!$password) { + $password = $this->getIo()->ask( + $this->trans('commands.user.password.hash.questions.password') + ); + $input->setArgument('password', [$password]); + } + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { $passwords = $input->getArgument('password'); $tableHeader = [ @@ -71,50 +83,6 @@ class PasswordHashCommand extends Command ]; } - $io->table($tableHeader, $tableRows, 'compact'); - } - - /** - * {@inheritdoc} - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $passwords = $input->getArgument('password'); - if (!$passwords) { - $passwords = []; - while (true) { - $password = $io->ask( - $this->trans('commands.user.password.hash.questions.password'), - '', - function ($pass) use ($passwords, $io) { - if (!empty($pass) || count($passwords) >= 1) { - if ($pass == '') { - return true; - } - - return $pass; - } else { - $io->error( - sprintf($this->trans('commands.user.password.hash.questions.invalid-pass'), $pass) - ); - - return false; - } - } - ); - - if ($password && !is_string($password)) { - break; - } - - if (is_string($password)) { - $passwords[] = $password; - } - } - - $input->setArgument('password', $passwords); - } + $this->getIo()->table($tableHeader, $tableRows, 'compact'); } }