a7ac4ecf316225b9284616ff8273a417d766178d
[yaffs-website] / vendor / drush / drush / src / Commands / generate / Generators / Migrate / MigrationGenerator.php
1 <?php
2
3 namespace Drush\Commands\generate\Generators\Migrate;
4
5 use DrupalCodeGenerator\Command\BaseGenerator;
6 use DrupalCodeGenerator\Utils;
7 use Symfony\Component\Console\Input\InputInterface;
8 use Symfony\Component\Console\Output\OutputInterface;
9 use Symfony\Component\Console\Question\Question;
10
11 /**
12  * Implements `generate migration` command.
13  */
14 class MigrationGenerator extends BaseGenerator
15 {
16
17     protected $name = 'migration';
18     protected $description = 'Generates the yml and PHP class for a Migration';
19     protected $templatePath = __DIR__;
20
21     /**
22      * {@inheritdoc}
23      */
24     protected function interact(InputInterface $input, OutputInterface $output)
25     {
26         $questions = Utils::defaultPluginQuestions() + [
27             'migration_group' => new Question('Migration group', 'default'),
28             'destination_plugin' => new Question('Destination plugin', 'entity:node'),
29         ];
30
31         $vars = &$this->collectVars($input, $output, $questions);
32         $vars['class'] = Utils::camelize($vars['plugin_label']);
33
34         $this->addFile()
35             ->path('src/Plugin/migrate/source/{class}.php')
36             ->template('migration.twig');
37
38         $this->addFile()
39             ->path('config/install/migrate_plus.migration.{plugin_id}.yml')
40             ->template('migration.yml.twig');
41     }
42 }