X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginMigrateProcessCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginMigrateProcessCommand.php;h=fccd9e35b736c69954f1df07b8552bd0678f3edb;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Command/Generate/PluginMigrateProcessCommand.php b/vendor/drupal/console/src/Command/Generate/PluginMigrateProcessCommand.php new file mode 100644 index 000000000..fccd9e35b --- /dev/null +++ b/vendor/drupal/console/src/Command/Generate/PluginMigrateProcessCommand.php @@ -0,0 +1,147 @@ +generator = $generator; + $this->chainQueue = $chainQueue; + $this->extensionManager = $extensionManager; + $this->stringConverter = $stringConverter; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('generate:plugin:migrate:process') + ->setDescription($this->trans('commands.generate.plugin.migrate.process.description')) + ->setHelp($this->trans('commands.generate.plugin.migrate.process.help')) + ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption( + 'class', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.process.options.class') + ) + ->addOption( + 'plugin-id', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.process.options.plugin-id') + ); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration + if (!$this->confirmGeneration($io)) { + return 1; + } + + $module = $input->getOption('module'); + $class_name = $input->getOption('class'); + $plugin_id = $input->getOption('plugin-id'); + + $this->generator->generate($module, $class_name, $plugin_id); + + $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + } + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // 'module-name' option. + $module = $input->getOption('module'); + if (!$module) { + // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion + $module = $this->moduleQuestion($io); + $input->setOption('module', $module); + } + + // 'class-name' option + $class = $input->getOption('class'); + if (!$class) { + $class = $io->ask( + $this->trans('commands.generate.plugin.migrate.process.questions.class'), + ucfirst($this->stringConverter->underscoreToCamelCase($module)) + ); + $input->setOption('class', $class); + } + + // 'plugin-id' option. + $pluginId = $input->getOption('plugin-id'); + if (!$pluginId) { + $pluginId = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.plugin-id'), + $this->stringConverter->camelCaseToUnderscore($class) + ); + $input->setOption('plugin-id', $pluginId); + } + } +}