Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console-core / src / Command / Debug / SiteCommand.php
similarity index 55%
rename from vendor/drupal/console-core/src/Command/Site/DebugCommand.php
rename to vendor/drupal/console-core/src/Command/Debug/SiteCommand.php
index 74ecad33b0824368de21eda7a866a845c2438a14..b496b2aa3af127d473989c18b34c6b22a5a08e2b 100644 (file)
@@ -2,36 +2,32 @@
 
 /**
  * @file
- * Contains \Drupal\Console\Core\Command\Site\DebugCommand.
+ * Contains \Drupal\Console\Core\Command\Debug\SiteCommand.
  */
 
-namespace Drupal\Console\Core\Command\Site;
+namespace Drupal\Console\Core\Command\Debug;
 
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Yaml\Dumper;
-use Symfony\Component\Console\Command\Command;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Console\Core\Utils\ConfigurationManager;
-use Drupal\Console\Core\Style\DrupalStyle;
 
 /**
- * Class SiteDebugCommand
+ * Class SiteCommand
  *
- * @package Drupal\Console\Core\Command\Site
+ * @package Drupal\Console\Core\Command\Debug
  */
-class DebugCommand extends Command
+class SiteCommand extends Command
 {
-    use CommandTrait;
-
     /**
      * @var ConfigurationManager
      */
     protected $configurationManager;
 
     /**
-     * DebugCommand constructor.
+     * SiteCommand constructor.
      *
      * @param ConfigurationManager $configurationManager
      */
@@ -48,21 +44,22 @@ class DebugCommand extends Command
     public function configure()
     {
         $this
-            ->setName('site:debug')
-            ->setDescription($this->trans('commands.site.debug.description'))
+            ->setName('debug:site')
+            ->setDescription($this->trans('commands.debug.site.description'))
             ->addArgument(
                 'target',
                 InputArgument::OPTIONAL,
-                $this->trans('commands.site.debug.options.target'),
+                $this->trans('commands.debug.site.options.target'),
                 null
             )
             ->addArgument(
                 'property',
                 InputArgument::OPTIONAL,
-                $this->trans('commands.site.debug.options.property'),
+                $this->trans('commands.debug.site.options.property'),
                 null
             )
-            ->setHelp($this->trans('commands.site.debug.help'));
+            ->setHelp($this->trans('commands.debug.site.help'))
+            ->setAliases(['dsi']);
     }
 
     /**
@@ -70,32 +67,37 @@ class DebugCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
-        $sites = array_keys($this->configurationManager->getSites());
+        $sites = $this->configurationManager->getSites();
 
         if (!$sites) {
-            $io->error($this->trans('commands.site.debug.messages.invalid-sites'));
+            $this->getIo()->warning($this->trans('commands.debug.site.messages.invalid-sites'));
 
-            return 1;
+            return 0;
         }
 
-
-        // --target argument
         $target = $input->getArgument('target');
         if (!$target) {
-            $tableHeader =[
-                $this->trans('commands.site.debug.messages.site'),
-            ];
-
-            $io->table($tableHeader, $sites);
+            foreach ($sites as $key => $site) {
+                $environments = array_keys($site);
+                unset($environments[0]);
+
+                $environments = array_map(
+                    function ($element) use ($key) {
+                        return $key . '.' . $element;
+                    },
+                    $environments
+                );
+
+                $this->getIo()->info($key);
+                $this->getIo()->listing($environments);
+            }
 
             return 0;
         }
 
         $targetConfig = $this->configurationManager->readTarget($target);
         if (!$targetConfig) {
-            $io->error($this->trans('commands.site.debug.messages.invalid-site'));
+            $this->getIo()->error($this->trans('commands.debug.site.messages.invalid-site'));
 
             return 1;
         }
@@ -110,13 +112,13 @@ class DebugCommand extends Command
                 $val = &$val[$property_key];
             }
 
-            $io->writeln($val);
+            $this->getIo()->writeln($val);
             return 0;
         }
 
-        $io->info($target);
+        $this->getIo()->info($target);
         $dumper = new Dumper();
-        $io->writeln($dumper->dump($targetConfig, 2));
+        $this->getIo()->writeln($dumper->dump($targetConfig, 4, 2));
 
         return 0;
     }