Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Config / EditCommand.php
index d142d711131b61cf244436a9a25786f0f4e8bfdb..564648cd62493c461d871401ab41b3b69f282a13 100644 (file)
@@ -17,15 +17,11 @@ use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
 use Drupal\Component\Serialization\Yaml;
 use Drupal\Core\Config\CachedStorage;
 use Drupal\Core\Config\ConfigFactory;
-use Symfony\Component\Console\Command\Command;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Console\Core\Utils\ConfigurationManager;
 
 class EditCommand extends Command
 {
-    use CommandTrait;
-
     /**
      * @var ConfigFactory
      */
@@ -75,7 +71,8 @@ class EditCommand extends Command
                 'editor',
                 InputArgument::OPTIONAL,
                 $this->trans('commands.config.edit.arguments.editor')
-            );
+            )
+            ->setAliases(['ced']);
     }
 
     /**
@@ -83,8 +80,6 @@ class EditCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $configName = $input->getArgument('config-name');
         $editor = $input->getArgument('editor');
         $config = $this->configFactory->getEditable($configName);
@@ -95,7 +90,7 @@ class EditCommand extends Command
         $fileSystem = new Filesystem();
 
         if (!$configName) {
-            $io->error($this->trans('commands.config.edit.messages.no-config'));
+            $this->getIo()->error($this->trans('commands.config.edit.messages.no-config'));
 
             return 1;
         }
@@ -104,7 +99,7 @@ class EditCommand extends Command
             $fileSystem->mkdir($temporaryDirectory);
             $fileSystem->dumpFile($configFile, $this->getYamlConfig($configName));
         } catch (IOExceptionInterface $e) {
-            $io->error($this->trans('commands.config.edit.messages.no-directory').' '.$e->getPath());
+            $this->getIo()->error($this->trans('commands.config.edit.messages.no-directory').' '.$e->getPath());
 
             return 1;
         }
@@ -124,7 +119,7 @@ class EditCommand extends Command
         }
 
         if (!$process->isSuccessful()) {
-            $io->error($process->getErrorOutput());
+            $this->getIo()->error($process->getErrorOutput());
             return 1;
         }
 
@@ -133,13 +128,11 @@ class EditCommand extends Command
 
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $configName = $input->getArgument('config-name');
         if (!$configName) {
             $configNames = $this->configFactory->listAll();
-            $configName = $io->choice(
-                'Choose a configuration',
+            $configName = $this->getIo()->choice(
+                $this->trans('commands.config.edit.messages.choose-configuration'),
                 $configNames
             );
 
@@ -168,7 +161,7 @@ class EditCommand extends Command
     protected function getEditor()
     {
         $config = $this->configurationManager->getConfiguration();
-        $editor = $config->get('application.editor', 'vi');
+        $editor = $config->get('application.editor', '');
 
         if ($editor != '') {
             return trim($editor);