Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Generate / PostUpdateCommand.php
index 180a70c0d34129bfb74152a93c7846ee2564f1f7..c58e970216d4eb53a06cce516b5578b43934049f 100644 (file)
@@ -13,11 +13,9 @@ use Symfony\Component\Console\Output\OutputInterface;
 use Drupal\Console\Generator\PostUpdateGenerator;
 use Drupal\Console\Command\Shared\ModuleTrait;
 use Drupal\Console\Command\Shared\ConfirmationTrait;
-use Symfony\Component\Console\Command\Command;
-use Drupal\Console\Core\Style\DrupalStyle;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Console\Extension\Manager;
 use Drupal\Console\Core\Utils\ChainQueue;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
 use Drupal\Console\Utils\Site;
 use Drupal\Console\Utils\Validator;
 
@@ -30,7 +28,6 @@ class PostUpdateCommand extends Command
 {
     use ModuleTrait;
     use ConfirmationTrait;
-    use CommandTrait;
 
     /**
  * @var Manager
@@ -85,7 +82,7 @@ class PostUpdateCommand extends Command
     {
         $this
             ->setName('generate:post:update')
-            ->setDescription($this->trans('commands.generate.post:update.description'))
+            ->setDescription($this->trans('commands.generate.post.update.description'))
             ->setHelp($this->trans('commands.generate.post.update.help'))
             ->addOption(
                 'module',
@@ -98,7 +95,7 @@ class PostUpdateCommand extends Command
                 null,
                 InputOption::VALUE_REQUIRED,
                 $this->trans('commands.generate.post.update.options.post-update-name')
-            );
+            )->setAliases(['gpu']);
     }
 
     /**
@@ -106,10 +103,8 @@ class PostUpdateCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
-        // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
-        if (!$this->confirmGeneration($io)) {
+        // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmOperation
+        if (!$this->confirmOperation()) {
             return 1;
         }
 
@@ -118,7 +113,10 @@ class PostUpdateCommand extends Command
 
         $this->validatePostUpdateName($module, $postUpdateName);
 
-        $this->generator->generate($module, $postUpdateName);
+        $this->generator->generate([
+            'module' => $module,
+            'post_update_name' => $postUpdateName,
+        ]);
 
         $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 
@@ -127,21 +125,15 @@ class PostUpdateCommand 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\Shared\ModuleTrait::moduleQuestion
-            $module = $this->moduleQuestion($io);
-            $input->setOption('module', $module);
-        }
+        // --module option
+        $this->getModuleOption();
 
         $postUpdateName = $input->getOption('post-update-name');
         if (!$postUpdateName) {
-            $postUpdateName = $io->ask(
+            $postUpdateName = $this->getIo()->ask(
                 $this->trans('commands.generate.post.update.questions.post-update-name'),
                 '',
                 function ($postUpdateName) {
@@ -153,12 +145,6 @@ class PostUpdateCommand extends Command
         }
     }
 
-
-    protected function createGenerator()
-    {
-        return new PostUpdateGenerator();
-    }
-
     protected function getLastUpdate($module)
     {
         $this->site->loadLegacyFile('/core/includes/update.inc');