Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Generate / HelpCommand.php
index 678ce71434f22455b65e413e2530d66837a85fc8..cd8e9b38b20de240f8a56b8c29e54d0f7fef1533 100644 (file)
@@ -10,25 +10,23 @@ namespace Drupal\Console\Command\Generate;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Console\Generator\HelpGenerator;
 use Drupal\Console\Command\Shared\ModuleTrait;
 use Drupal\Console\Command\Shared\ConfirmationTrait;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
 use Drupal\Console\Extension\Manager;
-use Drupal\Console\Core\Style\DrupalStyle;
 use Drupal\Console\Utils\Site;
 use Drupal\Console\Core\Utils\ChainQueue;
+use Drupal\Console\Utils\Validator;
 
 class HelpCommand extends Command
 {
-    use CommandTrait;
     use ModuleTrait;
     use ConfirmationTrait;
 
     /**
- * @var HelpGenerator
-*/
    * @var HelpGenerator
+     */
     protected $generator;
 
     /**
@@ -37,8 +35,8 @@ class HelpCommand extends Command
     protected $site;
 
     /**
- * @var Manager
-*/
    * @var Manager
+     */
     protected $extensionManager;
 
     /**
@@ -46,6 +44,11 @@ class HelpCommand extends Command
      */
     protected $chainQueue;
 
+    /**
+     * @var Validator
+     */
+    protected $validator;
+
 
     /**
      * HelpCommand constructor.
@@ -59,12 +62,14 @@ class HelpCommand extends Command
         HelpGenerator $generator,
         Site $site,
         Manager $extensionManager,
-        ChainQueue $chainQueue
+        ChainQueue $chainQueue,
+        Validator $validator
     ) {
         $this->generator = $generator;
         $this->site = $site;
         $this->extensionManager = $extensionManager;
         $this->chainQueue = $chainQueue;
+        $this->validator = $validator;
         parent::__construct();
     }
 
@@ -84,8 +89,8 @@ class HelpCommand extends Command
                 'description',
                 null,
                 InputOption::VALUE_OPTIONAL,
-                $this->trans('commands.generate.module.options.description')
-            );
+                $this->trans('commands.generate.help.options.description')
+            )->setAliases(['gh']);
     }
 
     /**
@@ -93,10 +98,8 @@ class HelpCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
-        // @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration
-        if (!$this->confirmGeneration($io)) {
+        // @see use Drupal\Console\Command\ConfirmationTrait::confirmOperation
+        if (!$this->confirmOperation()) {
             return 1;
         }
 
@@ -113,9 +116,10 @@ class HelpCommand extends Command
 
         $description = $input->getOption('description');
 
-        $this
-            ->generator
-            ->generate($module, $description);
+        $this->generator->generate([
+          'machine_name' => $module,
+          'description' => $description,
+        ]);
 
         $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 
@@ -124,23 +128,17 @@ class HelpCommand extends Command
 
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $this->site->loadLegacyFile('/core/includes/update.inc');
         $this->site->loadLegacyFile('/core/includes/schema.inc');
 
-        $module = $input->getOption('module');
-        if (!$module) {
-            // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
-            $module = $this->moduleQuestion($io);
-            $input->setOption('module', $module);
-        }
+        // --module option
+        $this->getModuleOption();
 
         $description = $input->getOption('description');
         if (!$description) {
-            $description = $io->ask(
-                $this->trans('commands.generate.module.questions.description'),
-                'My Awesome Module'
+            $description = $this->getIo()->ask(
+                $this->trans('commands.generate.help.questions.description'),
+                $this->trans('commands.generate.module.suggestions.my-awesome-module')
             );
         }
         $input->setOption('description', $description);