Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Config / DiffCommand.php
index 83470488e3c4c1752bac406c0d27a12c8a95ad48..c32881a3b60927a08a67839087db7a611bee9ea1 100644 (file)
@@ -12,16 +12,12 @@ use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Core\Config\CachedStorage;
 use Drupal\Core\Config\ConfigManager;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
 
 class DiffCommand extends Command
 {
-    use CommandTrait;
-
     /**
      * @var CachedStorage
      */
@@ -79,7 +75,7 @@ class DiffCommand extends Command
                 null,
                 InputOption::VALUE_NONE,
                 $this->trans('commands.config.diff.options.reverse')
-            );
+            )->setAliases(['cdi']);
     }
 
     /**
@@ -88,13 +84,12 @@ class DiffCommand extends Command
     protected function interact(InputInterface $input, OutputInterface $output)
     {
         global $config_directories;
-        $io = new DrupalStyle($input, $output);
 
         $directory = $input->getArgument('directory');
         if (!$directory) {
-            $directory = $io->choice(
+            $directory = $this->getIo()->choice(
                 $this->trans('commands.config.diff.questions.directories'),
-                array_keys($config_directories),
+                $config_directories,
                 CONFIG_SYNC_DIRECTORY
             );
 
@@ -107,8 +102,11 @@ class DiffCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-        $directory = $input->getArgument('directory');
+        global $config_directories;
+        $directory = $input->getArgument('directory') ?: CONFIG_SYNC_DIRECTORY;
+        if (array_key_exists($directory, $config_directories)) {
+            $directory = $config_directories[$directory];
+        }
         $source_storage = new FileStorage($directory);
 
         if ($input->getOption('reverse')) {
@@ -125,18 +123,16 @@ class DiffCommand extends Command
             $change_list[$collection] = $config_comparer->getChangelist(null, $collection);
         }
 
-        $this->outputDiffTable($io, $change_list);
+        $this->outputDiffTable($change_list);
     }
 
     /**
      * Ouputs a table of configuration changes.
      *
-     * @param DrupalStyle $io
-     *   The io.
      * @param array       $change_list
      *   The list of changes from the StorageComparer.
      */
-    protected function outputDiffTable(DrupalStyle $io, array $change_list)
+    protected function outputDiffTable(array $change_list)
     {
         $header = [
             $this->trans('commands.config.diff.table.headers.collection'),
@@ -155,6 +151,6 @@ class DiffCommand extends Command
                 }
             }
         }
-        $io->table($header, $rows);
+        $this->getIo()->table($header, $rows);
     }
 }