Skip to content

Commit

Permalink
[user:*] Update user commands. (#3683)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Jan 11, 2018
1 parent a8acc09 commit 98023b3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
9 changes: 1 addition & 8 deletions src/Command/User/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);

$user = $input->getOption('user');
if (!$user) {
$user = $io->askEmpty(
$this->trans('commands.user.delete.questions.user'),
null
);
$input->setOption('user', $user);
}
$user = $this->getUserOption();

$roles = $input->getOption('roles');

Expand Down
11 changes: 1 addition & 10 deletions src/Command/User/LoginCleanAttemptsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,7 @@ protected function configure()
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);

$user = $input->getArgument('user');
if (!$user) {
$user = $io->ask(
$this->trans('commands.user.login.clear.attempts.questions.user')
);

$input->setArgument('user', $user);
}
$this->getUserArgument();
}

/**
Expand Down
8 changes: 3 additions & 5 deletions src/Command/User/LoginUrlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ protected function configure()
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);

$this->userQuestion();
$this->getUserArgument();
}

/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
Expand Down
2 changes: 1 addition & 1 deletion src/Command/User/PasswordResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);

$this->userQuestion();
$this->getUserArgument();

$password = $input->getArgument('password');
if (!$password) {
Expand Down
27 changes: 21 additions & 6 deletions src/Command/User/UserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,35 @@ public function getUsers()
return $userList;
}

public function userQuestion()
private function userQuestion($user)
{
$input = $this->getIo()->getInput();
$user = $input->getArgument('user');

if (!$user) {
$user = $this->getIo()->choiceNoList(
$this->trans('commands.user.password.reset.questions.user'),
$this->getUsers()
);

$input->setArgument('user', $user);
}

return $user;
}

public function getUserOption()
{
$input = $this->getIo()->getInput();

$user = $this->userQuestion($input->getOption('user'));
$input->setOption('user', $user);

return $user;
}

public function getUserArgument()
{
$input = $this->getIo()->getInput();

$user = $this->userQuestion($input->getArgument('user'));
$input->setArgument('user', $user);

return $user;
}
}

0 comments on commit 98023b3

Please sign in to comment.