Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Config / ExportViewCommand.php
index f0b0c0e36c588b79a137947512ea48696d71c35a..dacc2bbbc87a094b499de711bad8290230276a62 100644 (file)
@@ -11,18 +11,16 @@ use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputOption;
 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\Console\Utils\Validator;
 use Drupal\Console\Command\Shared\ModuleTrait;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Config\CachedStorage;
-use Drupal\Console\Core\Style\DrupalStyle;
 use Drupal\Console\Command\Shared\ExportTrait;
 use Drupal\Console\Extension\Manager;
 
 class ExportViewCommand extends Command
 {
-    use CommandTrait;
     use ModuleTrait;
     use ExportTrait;
 
@@ -44,6 +42,11 @@ class ExportViewCommand extends Command
      */
     protected $extensionManager;
 
+    /**
+     * @var Validator
+     */
+    protected $validator;
+
     /**
      * ExportViewCommand constructor.
      *
@@ -54,11 +57,13 @@ class ExportViewCommand extends Command
     public function __construct(
         EntityTypeManagerInterface $entityTypeManager,
         CachedStorage $configStorage,
-        Manager $extensionManager
+        Manager $extensionManager,
+        Validator $validator
     ) {
         $this->entityTypeManager = $entityTypeManager;
         $this->configStorage = $configStorage;
         $this->extensionManager = $extensionManager;
+        $this->validator = $validator;
         parent::__construct();
     }
 
@@ -89,7 +94,8 @@ class ExportViewCommand extends Command
                 null,
                 InputOption::VALUE_OPTIONAL,
                 $this->trans('commands.config.export.view.options.include-module-dependencies')
-            );
+            )
+            ->setAliases(['cev']);
     }
 
     /**
@@ -97,15 +103,8 @@ class ExportViewCommand extends Command
      */
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         // --module option
-        $module = $input->getOption('module');
-        if (!$module) {
-            // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
-            $module = $this->moduleQuestion($io);
-            $input->setOption('module', $module);
-        }
+        $this->getModuleOption();
 
         // view-id argument
         $viewId = $input->getArgument('view-id');
@@ -117,7 +116,7 @@ class ExportViewCommand extends Command
                 $viewList[$view->get('id')] = $view->get('label');
             }
 
-            $viewId = $io->choiceNoList(
+            $viewId = $this->getIo()->choiceNoList(
                 $this->trans('commands.config.export.view.questions.view'),
                 $viewList
             );
@@ -126,7 +125,7 @@ class ExportViewCommand extends Command
 
         $optionalConfig = $input->getOption('optional-config');
         if (!$optionalConfig) {
-            $optionalConfig = $io->confirm(
+            $optionalConfig = $this->getIo()->confirm(
                 $this->trans('commands.config.export.view.questions.optional-config'),
                 true
             );
@@ -135,7 +134,7 @@ class ExportViewCommand extends Command
 
         $includeModuleDependencies = $input->getOption('include-module-dependencies');
         if (!$includeModuleDependencies) {
-            $includeModuleDependencies = $io->confirm(
+            $includeModuleDependencies = $this->getIo()->confirm(
                 $this->trans('commands.config.export.view.questions.include-module-dependencies'),
                 true
             );
@@ -145,8 +144,6 @@ class ExportViewCommand extends Command
 
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $module = $input->getOption('module');
         $viewId = $input->getArgument('view-id');
         $optionalConfig = $input->getOption('optional-config');
@@ -167,10 +164,10 @@ class ExportViewCommand extends Command
         // Include module dependencies in export files if export is not optional
         if ($includeModuleDependencies) {
             if ($dependencies = $this->fetchDependencies($viewNameConfig, 'module')) {
-                $this->exportModuleDependencies($io, $module, $dependencies);
+                $this->exportModuleDependencies($module, $dependencies);
             }
         }
 
-        $this->exportConfigToModule($module, $io, $this->trans('commands.views.export.messages.view_exported'));
+        $this->exportConfigToModule($module, $this->trans('commands.views.export.messages.view-exported'));
     }
 }