Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Debug / RolesCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Command\Roles\DebugCommand.
6  */
7
8 namespace Drupal\Console\Command\Debug;
9
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Drupal\Console\Core\Command\Command;
13 use Drupal\Console\Utils\DrupalApi;
14
15 /**
16  * Class RolesCommand
17  *
18  * @package Drupal\Console\Command\Debug
19  */
20 class RolesCommand extends Command
21 {
22     /**
23      * @var DrupalApi
24      */
25     protected $drupalApi;
26
27     /**
28      * DebugCommand constructor.
29      *
30      * @param DrupalApi $drupalApi
31      */
32     public function __construct(
33         DrupalApi $drupalApi
34     ) {
35         $this->drupalApi = $drupalApi;
36         parent::__construct();
37     }
38
39     /**
40      * {@inheritdoc}
41      */
42     protected function configure()
43     {
44         $this
45             ->setName('debug:roles')
46             ->setDescription($this->trans('commands.debug.roles.description'))
47             ->setAliases(['dusr']);
48     }
49
50     /**
51      * {@inheritdoc}
52      */
53     protected function execute(InputInterface $input, OutputInterface $output)
54     {
55         $roles = $this->drupalApi->getRoles();
56
57         $tableHeader = [
58             $this->trans('commands.debug.roles.messages.role-id'),
59             $this->trans('commands.debug.roles.messages.role-name'),
60         ];
61
62         $tableRows = [];
63         foreach ($roles as $roleId => $role) {
64             $tableRows[] = [
65                 $roleId,
66                 $role
67             ];
68         }
69
70         $this->getIo()->table($tableHeader, $tableRows);
71     }
72 }