Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Views / DisableCommand.php
index 146763ec9d433bc42d08e38a020c039e29a9ab77..dbee8f139c27fd239be886fda0a2f55c800a4203 100644 (file)
@@ -10,11 +10,9 @@ namespace Drupal\Console\Command\Views;
 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\Shared\CommandTrait;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Entity\Query\QueryFactory;
-use Drupal\Console\Core\Style\DrupalStyle;
 
 /**
  * Class DisableCommand
@@ -23,8 +21,6 @@ use Drupal\Console\Core\Style\DrupalStyle;
  */
 class DisableCommand extends Command
 {
-    use CommandTrait;
-
     /**
      * @var EntityTypeManagerInterface
      */
@@ -61,8 +57,9 @@ class DisableCommand extends Command
             ->addArgument(
                 'view-id',
                 InputArgument::OPTIONAL,
-                $this->trans('commands.views.debug.arguments.view-id')
-            );
+                $this->trans('commands.debug.views.arguments.view-id')
+            )
+            ->setAliases(['vd']);
     }
 
     /**
@@ -70,15 +67,14 @@ class DisableCommand extends Command
      */
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
         $viewId = $input->getArgument('view-id');
         if (!$viewId) {
             $views = $this->entityQuery
                 ->get('view')
                 ->condition('status', 1)
                 ->execute();
-            $viewId = $io->choiceNoList(
-                $this->trans('commands.views.debug.arguments.view-id'),
+            $viewId = $this->getIo()->choiceNoList(
+                $this->trans('commands.debug.views.arguments.view-id'),
                 $views
             );
             $input->setArgument('view-id', $viewId);
@@ -90,14 +86,12 @@ class DisableCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $viewId = $input->getArgument('view-id');
 
         $view = $this->entityTypeManager->getStorage('view')->load($viewId);
 
         if (empty($view)) {
-            $io->error(sprintf($this->trans('commands.views.debug.messages.not-found'), $viewId));
+            $this->getIo()->error(sprintf($this->trans('commands.debug.views.messages.not-found'), $viewId));
 
             return 1;
         }
@@ -105,9 +99,9 @@ class DisableCommand extends Command
         try {
             $view->disable()->save();
 
-            $io->success(sprintf($this->trans('commands.views.disable.messages.disabled-successfully'), $view->get('label')));
+            $this->getIo()->success(sprintf($this->trans('commands.views.disable.messages.disabled-successfully'), $view->get('label')));
         } catch (\Exception $e) {
-            $io->error($e->getMessage());
+            $this->getIo()->error($e->getMessage());
 
             return 1;
         }