Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Debug / RolesCommand.php
diff --git a/vendor/drupal/console/src/Command/Debug/RolesCommand.php b/vendor/drupal/console/src/Command/Debug/RolesCommand.php
new file mode 100644 (file)
index 0000000..c1b1d53
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Console\Command\Roles\DebugCommand.
+ */
+
+namespace Drupal\Console\Command\Debug;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Drupal\Console\Core\Command\Command;
+use Drupal\Console\Utils\DrupalApi;
+
+/**
+ * Class RolesCommand
+ *
+ * @package Drupal\Console\Command\Debug
+ */
+class RolesCommand extends Command
+{
+    /**
+     * @var DrupalApi
+     */
+    protected $drupalApi;
+
+    /**
+     * DebugCommand constructor.
+     *
+     * @param DrupalApi $drupalApi
+     */
+    public function __construct(
+        DrupalApi $drupalApi
+    ) {
+        $this->drupalApi = $drupalApi;
+        parent::__construct();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function configure()
+    {
+        $this
+            ->setName('debug:roles')
+            ->setDescription($this->trans('commands.debug.roles.description'))
+            ->setAliases(['dusr']);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        $roles = $this->drupalApi->getRoles();
+
+        $tableHeader = [
+            $this->trans('commands.debug.roles.messages.role-id'),
+            $this->trans('commands.debug.roles.messages.role-name'),
+        ];
+
+        $tableRows = [];
+        foreach ($roles as $roleId => $role) {
+            $tableRows[] = [
+                $roleId,
+                $role
+            ];
+        }
+
+        $this->getIo()->table($tableHeader, $tableRows);
+    }
+}