More tidying.
[yaffs-website] / vendor / drupal / console / src / Command / Migrate / DebugCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Command\Migrate\DebugCommand.
6  */
7
8 namespace Drupal\Console\Command\Migrate;
9
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Console\Command\Shared\MigrationTrait;
14 use Drupal\Console\Core\Style\DrupalStyle;
15 use Drupal\Console\Annotations\DrupalCommand;
16 use Symfony\Component\Console\Command\Command;
17 use Drupal\Console\Core\Command\Shared\CommandTrait;
18 use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
19
20 /**
21  * @DrupalCommand(
22  *     extension = "migrate",
23  *     extensionType = "module"
24  * )
25  */
26
27 class DebugCommand extends Command
28 {
29     use MigrationTrait;
30     use CommandTrait;
31
32     /**
33      * @var MigrationPluginManagerInterface $pluginManagerMigration
34      */
35     protected $pluginManagerMigration;
36
37     /**
38      * DebugCommand constructor.
39      *
40      * @param MigrationPluginManagerInterface $pluginManagerMigration
41      */
42     public function __construct(MigrationPluginManagerInterface $pluginManagerMigration)
43     {
44         $this->pluginManagerMigration = $pluginManagerMigration;
45         parent::__construct();
46     }
47
48     protected function configure()
49     {
50         $this
51             ->setName('migrate:debug')
52             ->setDescription($this->trans('commands.migrate.debug.description'))
53             ->addArgument(
54                 'tag',
55                 InputArgument::OPTIONAL,
56                 $this->trans('commands.migrate.debug.arguments.tag')
57             );
58     }
59
60     protected function execute(InputInterface $input, OutputInterface $output)
61     {
62         $io = new DrupalStyle($input, $output);
63         $drupal_version = 'Drupal ' . $input->getArgument('tag');
64         
65         $migrations = $this->getMigrations($drupal_version);
66         
67
68         $tableHeader = [
69           $this->trans('commands.migrate.debug.messages.id'),
70           $this->trans('commands.migrate.debug.messages.description'),
71           $this->trans('commands.migrate.debug.messages.tags'),
72         ];
73
74         $tableRows = [];
75         if (empty($migrations)) {
76             $io->error(
77                 sprintf(
78                     $this->trans('commands.migrate.debug.messages.no-migrations'),
79                     count($migrations)
80                 )
81             );
82         }
83         foreach ($migrations as $migration_id => $migration) {
84             $tableRows[] = [$migration_id, $migration['description'], $migration['tags']];
85         }
86         $io->table($tableHeader, $tableRows, 'compact');
87     }
88 }