Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Migrate / RollBackCommand.php
index 91a2fe202a362763b11a99e826f7e3cfd36b8183..72eca44634bffd257a4e96f27d73b96d62f0b4b0 100644 (file)
@@ -12,10 +12,8 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Drupal\Console\Command\Shared\MigrationTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
 use Drupal\Console\Annotations\DrupalCommand;
-use Symfony\Component\Console\Command\Command;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
+use Drupal\Console\Core\Command\Command;
 use Drupal\migrate_plus\Entity\MigrationGroup;
 use Drupal\migrate\Plugin\MigrationInterface;
 use Drupal\migrate\MigrateExecutable;
@@ -28,11 +26,9 @@ use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
  *     extensionType = "module"
  * )
  */
-
 class RollBackCommand extends Command
 {
     use MigrationTrait;
-    use CommandTrait;
 
     /**
      * @var MigrationPluginManagerInterface $pluginManagerMigration
@@ -44,8 +40,9 @@ class RollBackCommand extends Command
      *
      * @param MigrationPluginManagerInterface $pluginManagerMigration
      */
-    public function __construct(MigrationPluginManagerInterface $pluginManagerMigration)
-    {
+    public function __construct(
+        MigrationPluginManagerInterface $pluginManagerMigration
+    ) {
         $this->pluginManagerMigration = $pluginManagerMigration;
         parent::__construct();
     }
@@ -60,14 +57,13 @@ class RollBackCommand extends Command
                 'source-base_path',
                 null,
                 InputOption::VALUE_OPTIONAL,
-                $this->trans('commands.migrate.setup.options.source-base_path')
-            );
+                $this->trans('commands.migrate.setup.options.source-base-path')
+            )->setAliases(['mir']);
+        ;
     }
 
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $sourceBasepath = $input->getOption('source-base_path');
         $configuration['source']['constants']['source_base_path'] = rtrim($sourceBasepath, '/') . '/';
         // --migration-id prefix
@@ -87,7 +83,7 @@ class RollBackCommand extends Command
 
         foreach ($migration_ids as  $migration) {
             if (!in_array($migration, $migrations_list)) {
-                $io->warning(
+                $this->getIo()->warning(
                     sprintf(
                         $this->trans('commands.migrate.rollback.messages.not-available'),
                         $migration
@@ -103,7 +99,7 @@ class RollBackCommand extends Command
                 $migration_status = $executable->rollback();
                 switch ($migration_status) {
                 case MigrationInterface::RESULT_COMPLETED:
-                    $io->info(
+                    $this->getIo()->info(
                         sprintf(
                             $this->trans('commands.migrate.rollback.messages.processing'),
                             $migration
@@ -111,7 +107,7 @@ class RollBackCommand extends Command
                     );
                     break;
                 case MigrationInterface::RESULT_INCOMPLETE:
-                    $io->info(
+                    $this->getIo()->info(
                         sprintf(
                             $this->trans('commands.migrate.execute.messages.importing-incomplete'),
                             $migration
@@ -119,7 +115,7 @@ class RollBackCommand extends Command
                     );
                     break;
                 case MigrationInterface::RESULT_STOPPED:
-                    $io->error(
+                    $this->getIo()->error(
                         sprintf(
                             $this->trans('commands.migrate.execute.messages.import-stopped'),
                             $migration
@@ -138,7 +134,6 @@ class RollBackCommand extends Command
      */
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
         // Get migrations
         $migrations_list = $this->getMigrations($version_tag);
 
@@ -150,7 +145,7 @@ class RollBackCommand extends Command
             $migrations_ids = [];
 
             while (true) {
-                $migration_id = $io->choiceNoList(
+                $migration_id = $this->getIo()->choiceNoList(
                     $this->trans('commands.migrate.execute.questions.id'),
                     array_keys($migrations_list),
                     'all'
@@ -173,8 +168,8 @@ class RollBackCommand extends Command
         // --source-base_path
         $sourceBasepath = $input->getOption('source-base_path');
         if (!$sourceBasepath) {
-            $sourceBasepath = $io->ask(
-                $this->trans('commands.migrate.setup.questions.source-base_path'),
+            $sourceBasepath = $this->getIo()->ask(
+                $this->trans('commands.migrate.setup.questions.source-base-path'),
                 ''
             );
             $input->setOption('source-base_path', $sourceBasepath);