5 * Contains \Drupal\Console\Command\Create\RolesCommand.
8 namespace Drupal\Console\Command\Create;
10 use Drupal\Console\Utils\Create\RoleData;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Input\InputOption;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Drupal\Console\Core\Command\Command;
19 * @package Drupal\Console\Command\Create
21 class RolesCommand extends Command
26 protected $createRoleData;
29 * RolesCommand constructor.
31 * @param RoleData $createRoleData
33 public function __construct(
34 RoleData $createRoleData
36 $this->createRoleData = $createRoleData;
37 parent::__construct();
43 protected function configure()
46 ->setName('create:roles')
47 ->setDescription($this->trans('commands.create.roles.description'))
51 InputOption::VALUE_OPTIONAL,
52 $this->trans('commands.create.roles.options.limit')
54 ->setAliases(['crr']);
60 protected function interact(InputInterface $input, OutputInterface $output)
62 $limit = $input->getOption('limit');
64 $limit = $this->getIo()->ask(
65 $this->trans('commands.create.roles.questions.limit'),
68 $input->setOption('limit', $limit);
75 protected function execute(InputInterface $input, OutputInterface $output)
77 $limit = $input->getOption('limit')?:5;
79 $result = $this->createRoleData->create(
84 $this->trans('commands.create.roles.messages.role-id'),
85 $this->trans('commands.create.roles.messages.role-name'),
88 if ($result['success']) {
89 $this->getIo()->table($tableHeader, $result['success']);
91 $this->getIo()->success(
93 $this->trans('commands.create.roles.messages.created-roles'),
94 count($result['success'])
99 if (isset($result['error'])) {
100 foreach ($result['error'] as $error) {
101 $this->getIo()->error(
103 $this->trans('commands.create.roles.messages.error'),