Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Debug / PluginCommand.php
similarity index 67%
rename from vendor/drupal/console/src/Command/PluginDebugCommand.php
rename to vendor/drupal/console/src/Command/Debug/PluginCommand.php
index 3f3ebe9b16dad1529bb5e04b530d3036f93eedda..f6a661d8e91d1df10ecaba01905139977ab64f03 100644 (file)
@@ -5,42 +5,39 @@
  * Contains \Drupal\Console\Command\PluginDebugCommand.
  */
 
-namespace Drupal\Console\Command;
+namespace Drupal\Console\Command\Debug;
 
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\ContainerAwareCommand;
 use Symfony\Component\Yaml\Yaml;
-use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
 
 /**
  * Class DebugCommand
  *
- * @package Drupal\Console\Command
+ * @package Drupal\Console\Command\Debug
  */
-class PluginDebugCommand extends Command
+class PluginCommand extends ContainerAwareCommand
 {
-    use ContainerAwareCommandTrait;
     /**
      * {@inheritdoc}
      */
     protected function configure()
     {
-        $this->setName('plugin:debug')
-            ->setDescription($this->trans('commands.plugin.debug.description'))
-            ->setHelp($this->trans('commands.plugin.debug.help'))
+        $this->setName('debug:plugin')
+            ->setDescription($this->trans('commands.debug.plugin.description'))
+            ->setHelp($this->trans('commands.debug.plugin.help'))
             ->addArgument(
                 'type',
                 InputArgument::OPTIONAL,
-                $this->trans('commands.plugin.debug.arguments.type')
+                $this->trans('commands.debug.plugin.arguments.type')
             )
             ->addArgument(
                 'id',
                 InputArgument::OPTIONAL,
-                $this->trans('commands.plugin.debug.arguments.id')
-            );
+                $this->trans('commands.debug.plugin.arguments.id')
+            )->setAliases(['dpl']);
     }
 
     /**
@@ -48,20 +45,17 @@ class PluginDebugCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $pluginType = $input->getArgument('type');
         $pluginId = $input->getArgument('id');
 
         // No plugin type specified, show a list of plugin types.
         if (!$pluginType) {
             $tableHeader = [
-                $this->trans('commands.plugin.debug.table-headers.plugin-type-name'),
-                $this->trans('commands.plugin.debug.table-headers.plugin-type-class')
+                $this->trans('commands.debug.plugin.table-headers.plugin-type-name'),
+                $this->trans('commands.debug.plugin.table-headers.plugin-type-class')
             ];
             $tableRows = [];
-            $serviceDefinitions = $this->container
-                ->getParameter('console.service_definitions');
+            $serviceDefinitions = $this->container->getDefinitions();
 
             foreach ($serviceDefinitions as $serviceId => $serviceDefinition) {
                 if (strpos($serviceId, 'plugin.manager.') === 0) {
@@ -74,16 +68,16 @@ class PluginDebugCommand extends Command
             }
 
             ksort($tableRows);
-            $io->table($tableHeader, array_values($tableRows));
+            $this->getIo()->table($tableHeader, array_values($tableRows));
 
             return true;
         }
 
         $service = $this->container->get('plugin.manager.' . $pluginType);
         if (!$service) {
-            $io->error(
+            $this->getIo()->error(
                 sprintf(
-                    $this->trans('commands.plugin.debug.errors.plugin-type-not-found'),
+                    $this->trans('commands.debug.plugin.errors.plugin-type-not-found'),
                     $pluginType
                 )
             );
@@ -93,8 +87,8 @@ class PluginDebugCommand extends Command
         // Valid plugin type specified, no ID specified, show list of instances.
         if (!$pluginId) {
             $tableHeader = [
-                $this->trans('commands.plugin.debug.table-headers.plugin-id'),
-                $this->trans('commands.plugin.debug.table-headers.plugin-class')
+                $this->trans('commands.debug.plugin.table-headers.plugin-id'),
+                $this->trans('commands.debug.plugin.table-headers.plugin-class')
             ];
             $tableRows = [];
             foreach ($service->getDefinitions() as $definition) {
@@ -103,15 +97,15 @@ class PluginDebugCommand extends Command
                 $tableRows[$pluginId] = [$pluginId, $className];
             }
             ksort($tableRows);
-            $io->table($tableHeader, array_values($tableRows));
+            $this->getIo()->table($tableHeader, array_values($tableRows));
             return true;
         }
 
         // Valid plugin type specified, ID specified, show the definition.
         $definition = $service->getDefinition($pluginId);
         $tableHeader = [
-            $this->trans('commands.plugin.debug.table-headers.definition-key'),
-            $this->trans('commands.plugin.debug.table-headers.definition-value')
+            $this->trans('commands.debug.plugin.table-headers.definition-key'),
+            $this->trans('commands.debug.plugin.table-headers.definition-value')
         ];
         $tableRows = [];
         foreach ($definition as $key => $value) {
@@ -125,7 +119,7 @@ class PluginDebugCommand extends Command
             $tableRows[$key] = [$key, $value];
         }
         ksort($tableRows);
-        $io->table($tableHeader, array_values($tableRows));
+        $this->getIo()->table($tableHeader, array_values($tableRows));
         return true;
     }
 }