Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Config / DeleteCommand.php
index 7ab29c664685f9791123881a5f467b9fd6a82e9c..7c1922b1c855faa174ab92cdba0fc70e304123ea 100644 (file)
@@ -10,17 +10,13 @@ use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Yaml\Exception\RuntimeException;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Core\Config\StorageInterface;
 use Drupal\Core\Config\CachedStorage;
 use Drupal\Core\Config\ConfigFactory;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
 
 class DeleteCommand extends Command
 {
-    use CommandTrait;
-
     protected $allConfig = [];
 
     /**
@@ -73,7 +69,7 @@ class DeleteCommand extends Command
                 'name',
                 InputArgument::OPTIONAL,
                 $this->trans('commands.config.delete.arguments.name')
-            );
+            )->setAliases(['cd']);
     }
 
     /**
@@ -81,11 +77,9 @@ class DeleteCommand extends Command
      */
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $type = $input->getArgument('type');
         if (!$type) {
-            $type = $io->choiceNoList(
+            $type = $this->getIo()->choiceNoList(
                 $this->trans('commands.config.delete.arguments.type'),
                 ['active', 'staging'],
                 'active'
@@ -95,7 +89,7 @@ class DeleteCommand extends Command
 
         $name = $input->getArgument('name');
         if (!$name) {
-            $name = $io->choiceNoList(
+            $name = $this->getIo()->choiceNoList(
                 $this->trans('commands.config.delete.arguments.name'),
                 $this->getAllConfigNames(),
                 'all'
@@ -109,30 +103,28 @@ class DeleteCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $type = $input->getArgument('type');
         if (!$type) {
-            $io->error($this->trans('commands.config.delete.errors.type'));
+            $this->getIo()->error($this->trans('commands.config.delete.errors.type'));
             return 1;
         }
 
         $name = $input->getArgument('name');
         if (!$name) {
-            $io->error($this->trans('commands.config.delete.errors.name'));
+            $this->getIo()->error($this->trans('commands.config.delete.errors.name'));
             return 1;
         }
 
         $configStorage = ('active' === $type) ? $this->configStorage : $this->configStorageSync;
 
         if (!$configStorage) {
-            $io->error($this->trans('commands.config.delete.errors.config-storage'));
+            $this->getIo()->error($this->trans('commands.config.delete.errors.config-storage'));
             return 1;
         }
 
         if ('all' === $name) {
-            $io->commentBlock($this->trans('commands.config.delete.warnings.undo'));
-            if ($io->confirm($this->trans('commands.config.delete.questions.sure'))) {
+            $this->getIo()->commentBlock($this->trans('commands.config.delete.warnings.undo'));
+            if ($this->getIo()->confirm($this->trans('commands.config.delete.questions.sure'))) {
                 if ($configStorage instanceof FileStorage) {
                     $configStorage->deleteAll();
                 } else {
@@ -141,7 +133,7 @@ class DeleteCommand extends Command
                     }
                 }
 
-                $io->success($this->trans('commands.config.delete.messages.all'));
+                $this->getIo()->success($this->trans('commands.config.delete.messages.all'));
 
                 return 0;
             }
@@ -154,7 +146,7 @@ class DeleteCommand extends Command
                 $this->removeConfig($name);
             }
 
-            $io->success(
+            $this->getIo()->success(
                 sprintf(
                     $this->trans('commands.config.delete.messages.deleted'),
                     $name
@@ -164,7 +156,7 @@ class DeleteCommand extends Command
         }
 
         $message = sprintf($this->trans('commands.config.delete.errors.not-exists'), $name);
-        $io->error($message);
+        $this->getIo()->error($message);
 
         return 1;
     }