Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Config / OverrideCommand.php
index 2f690ef44f6f3b006919a234ef8d0eda5359da46..eebf466c3ed0c486d41527ea6dbb625216184b54 100644 (file)
@@ -10,16 +10,12 @@ namespace Drupal\Console\Command\Config;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 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\ConfigFactory;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
 
 class OverrideCommand extends Command
 {
-    use CommandTrait;
-
     /**
      * @var CachedStorage
      */
@@ -55,8 +51,17 @@ class OverrideCommand extends Command
                 InputArgument::REQUIRED,
                 $this->trans('commands.config.override.arguments.name')
             )
-            ->addArgument('key', InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.key'))
-            ->addArgument('value', InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.value'));
+            ->addArgument(
+                'key',
+                InputArgument::REQUIRED,
+                $this->trans('commands.config.override.arguments.key')
+            )
+            ->addArgument(
+                'value',
+                InputArgument::REQUIRED,
+                $this->trans('commands.config.override.arguments.value')
+            )
+            ->setAliases(['co']);
     }
 
     /**
@@ -64,12 +69,11 @@ class OverrideCommand extends Command
      */
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
         $name = $input->getArgument('name');
         $names = $this->configFactory->listAll();
         if ($name) {
             if (!in_array($name, $names)) {
-                $io->warning(
+                $this->getIo()->warning(
                     sprintf(
                         $this->trans('commands.config.override.messages.invalid-name'),
                         $name
@@ -79,7 +83,7 @@ class OverrideCommand extends Command
             }
         }
         if (!$name) {
-            $name = $io->choiceNoList(
+            $name = $this->getIo()->choiceNoList(
                 $this->trans('commands.config.override.questions.name'),
                 $names
             );
@@ -90,7 +94,7 @@ class OverrideCommand extends Command
             if ($this->configStorage->exists($name)) {
                 $configuration = $this->configStorage->read($name);
             }
-            $key = $io->choiceNoList(
+            $key = $this->getIo()->choiceNoList(
                 $this->trans('commands.config.override.questions.key'),
                 array_keys($configuration)
             );
@@ -98,7 +102,7 @@ class OverrideCommand extends Command
         }
         $value = $input->getArgument('value');
         if (!$value) {
-            $value = $io->ask(
+            $value = $this->getIo()->ask(
                 $this->trans('commands.config.override.questions.value')
             );
             $input->setArgument('value', $value);
@@ -109,20 +113,22 @@ class OverrideCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $configName = $input->getArgument('name');
         $key = $input->getArgument('key');
         $value = $input->getArgument('value');
 
         $config = $this->configFactory->getEditable($configName);
 
-        $configurationOverrideResult = $this->overrideConfiguration($config, $key, $value);
+        $configurationOverrideResult = $this->overrideConfiguration(
+            $config,
+            $key,
+            $value
+        );
 
         $config->save();
 
-        $io->info($this->trans('commands.config.override.messages.configuration'), false);
-        $io->comment($configName);
+        $this->getIo()->info($this->trans('commands.config.override.messages.configuration'), false);
+        $this->getIo()->comment($configName);
 
         $tableHeader = [
             $this->trans('commands.config.override.messages.configuration-key'),
@@ -130,9 +136,7 @@ class OverrideCommand extends Command
             $this->trans('commands.config.override.messages.updated'),
         ];
         $tableRows = $configurationOverrideResult;
-        $io->table($tableHeader, $tableRows);
-
-        $config->save();
+        $this->getIo()->table($tableHeader, $tableRows);
     }