Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Views / EnableCommand.php
index 898d17eead02511486c830f4aa4999f2af02806d..5102bbf682c0b38317af6145257199065492aacc 100644 (file)
@@ -11,11 +11,9 @@ use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Config\Definition\Exception\Exception;
-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 EnableCommand
@@ -24,8 +22,6 @@ use Drupal\Console\Core\Style\DrupalStyle;
  */
 class EnableCommand extends Command
 {
-    use CommandTrait;
-
     /**
      * @var EntityTypeManagerInterface
      */
@@ -62,8 +58,9 @@ class EnableCommand extends Command
             ->addArgument(
                 'view-id',
                 InputArgument::OPTIONAL,
-                $this->trans('commands.views.debug.arguments.view-id')
-            );
+                $this->trans('commands.debug.views.arguments.view-id')
+            )
+            ->setAliases(['ve']);
     }
 
     /**
@@ -71,15 +68,14 @@ class EnableCommand 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', 0)
                 ->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);
@@ -91,15 +87,14 @@ class EnableCommand 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(
+            $this->getIo()->error(
                 sprintf(
-                    $this->trans('commands.views.debug.messages.not-found'),
+                    $this->trans('commands.debug.views.messages.not-found'),
                     $viewId
                 )
             );
@@ -108,14 +103,14 @@ class EnableCommand extends Command
 
         try {
             $view->enable()->save();
-            $io->success(
+            $this->getIo()->success(
                 sprintf(
                     $this->trans('commands.views.enable.messages.enabled-successfully'),
                     $view->get('label')
                 )
             );
         } catch (Exception $e) {
-            $io->error($e->getMessage());
+            $this->getIo()->error($e->getMessage());
 
             return 1;
         }