X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FCreate%2FUsersCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FCreate%2FUsersCommand.php;h=73423dd36d5a4a05d1a4cf8a912f238b90618c7b;hp=4fc6c1f748819b971558a33348d221c30960af08;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console/src/Command/Create/UsersCommand.php b/vendor/drupal/console/src/Command/Create/UsersCommand.php index 4fc6c1f74..73423dd36 100644 --- a/vendor/drupal/console/src/Command/Create/UsersCommand.php +++ b/vendor/drupal/console/src/Command/Create/UsersCommand.php @@ -11,12 +11,10 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; 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\Console\Command\Shared\CreateTrait; use Drupal\Console\Utils\Create\UserData; use Drupal\Console\Utils\DrupalApi; -use Drupal\Console\Core\Style\DrupalStyle; /** * Class UsersCommand @@ -26,7 +24,6 @@ use Drupal\Console\Core\Style\DrupalStyle; class UsersCommand extends Command { use CreateTrait; - use CommandTrait; /** * @var DrupalApi @@ -82,7 +79,7 @@ class UsersCommand extends Command null, InputOption::VALUE_OPTIONAL, $this->trans('commands.create.users.options.time-range') - ); + )->setAliases(['cru']); } /** @@ -90,12 +87,10 @@ class UsersCommand extends Command */ protected function interact(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - $rids = $input->getArgument('roles'); if (!$rids) { $roles = $this->drupalApi->getRoles(); - $rids = $io->choice( + $rids = $this->getIo()->choice( $this->trans('commands.create.users.questions.roles'), array_values($roles), null, @@ -114,7 +109,7 @@ class UsersCommand extends Command $limit = $input->getOption('limit'); if (!$limit) { - $limit = $io->ask( + $limit = $this->getIo()->ask( $this->trans('commands.create.users.questions.limit'), 10 ); @@ -123,7 +118,7 @@ class UsersCommand extends Command $password = $input->getOption('password'); if (!$password) { - $password = $io->ask( + $password = $this->getIo()->ask( $this->trans('commands.create.users.questions.password'), 5 ); @@ -135,7 +130,7 @@ class UsersCommand extends Command if (!$timeRange) { $timeRanges = $this->getTimeRange(); - $timeRange = $io->choice( + $timeRange = $this->getIo()->choice( $this->trans('commands.create.nodes.questions.time-range'), array_values($timeRanges) ); @@ -149,8 +144,6 @@ class UsersCommand extends Command */ protected function execute(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - $roles = $input->getArgument('roles'); $limit = $input->getOption('limit')?:25; $password = $input->getOption('password'); @@ -160,7 +153,7 @@ class UsersCommand extends Command $roles = $this->drupalApi->getRoles(); } - $users = $this->createUserData->create( + $result = $this->createUserData->create( $roles, $limit, $password, @@ -174,17 +167,28 @@ class UsersCommand extends Command $this->trans('commands.create.users.messages.created'), ]; - if ($users['success']) { - $io->table($tableHeader, $users['success']); + if ($result['success']) { + $this->getIo()->table($tableHeader, $result['success']); - $io->success( + $this->getIo()->success( sprintf( $this->trans('commands.create.users.messages.created-users'), - $limit + count($result['success']) ) ); } + if (isset($result['error'])) { + foreach ($result['error'] as $error) { + $this->getIo()->error( + sprintf( + $this->trans('commands.create.users.messages.error'), + $error + ) + ); + } + } + return 0; } }