X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginMigrateSourceCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginMigrateSourceCommand.php;h=8476a1e0698df3afab6ce638bfeec0d801f10984;hp=5de03cccfa90eb1ae7f98a8b68784bf38418e4bf;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console/src/Command/Generate/PluginMigrateSourceCommand.php b/vendor/drupal/console/src/Command/Generate/PluginMigrateSourceCommand.php index 5de03cccf..8476a1e06 100644 --- a/vendor/drupal/console/src/Command/Generate/PluginMigrateSourceCommand.php +++ b/vendor/drupal/console/src/Command/Generate/PluginMigrateSourceCommand.php @@ -10,25 +10,22 @@ namespace Drupal\Console\Command\Generate; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Console\Generator\PluginMigrateSourceGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait; use Drupal\Console\Extension\Manager; use Drupal\Console\Utils\Validator; use Drupal\Console\Core\Utils\StringConverter; -use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Render\ElementInfoManagerInterface; -class PluginMigrateSourceCommand extends Command +class PluginMigrateSourceCommand extends ContainerAwareCommand { use ModuleTrait; use ConfirmationTrait; - use ContainerAwareCommandTrait; /** * @var ConfigFactory @@ -109,7 +106,12 @@ class PluginMigrateSourceCommand extends Command ->setName('generate:plugin:migrate:source') ->setDescription($this->trans('commands.generate.plugin.migrate.source.description')) ->setHelp($this->trans('commands.generate.plugin.migrate.source.help')) - ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption( + 'module', + null, + InputOption::VALUE_REQUIRED, + $this->trans('commands.common.options.module') + ) ->addOption( 'class', null, @@ -145,7 +147,7 @@ class PluginMigrateSourceCommand extends Command null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.generate.plugin.migrate.source.options.fields') - ); + )->setAliases(['gpms']); } /** @@ -153,49 +155,40 @@ class PluginMigrateSourceCommand 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; } $module = $input->getOption('module'); - $class_name = $input->getOption('class'); + $class_name = $this->validator->validateClassName($input->getOption('class')); $plugin_id = $input->getOption('plugin-id'); $table = $input->getOption('table'); $alias = $input->getOption('alias'); $group_by = $input->getOption('group-by'); $fields = $input->getOption('fields'); - $this->generator - ->generate( - $module, - $class_name, - $plugin_id, - $table, - $alias, - $group_by, - $fields - ); + $this->generator->generate([ + 'module' => $module, + 'class_name' => $class_name, + 'plugin_id' => $plugin_id, + 'table' => $table, + 'alias' => $alias, + 'group_by' => $group_by, + 'fields' => $fields, + ]); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); } protected function interact(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - - $module = $input->getOption('module'); - if (!$module) { - // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion - $module = $this->moduleQuestion($io); - $input->setOption('module', $module); - } + // 'module-name' option. + $module = $this->getModuleOption(); $class = $input->getOption('class'); if (!$class) { - $class = $io->ask( + $class = $this->getIo()->ask( $this->trans('commands.generate.plugin.migrate.source.questions.class'), ucfirst($this->stringConverter->underscoreToCamelCase($module)), function ($class) { @@ -207,7 +200,7 @@ class PluginMigrateSourceCommand extends Command $pluginId = $input->getOption('plugin-id'); if (!$pluginId) { - $pluginId = $io->ask( + $pluginId = $this->getIo()->ask( $this->trans('commands.generate.plugin.migrate.source.questions.plugin-id'), $this->stringConverter->camelCaseToUnderscore($class) ); @@ -216,7 +209,7 @@ class PluginMigrateSourceCommand extends Command $table = $input->getOption('table'); if (!$table) { - $table = $io->ask( + $table = $this->getIo()->ask( $this->trans('commands.generate.plugin.migrate.source.questions.table'), '' ); @@ -225,7 +218,7 @@ class PluginMigrateSourceCommand extends Command $alias = $input->getOption('alias'); if (!$alias) { - $alias = $io->ask( + $alias = $this->getIo()->ask( $this->trans('commands.generate.plugin.migrate.source.questions.alias'), substr($table, 0, 1) ); @@ -234,7 +227,7 @@ class PluginMigrateSourceCommand extends Command $groupBy = $input->getOption('group-by'); if ($groupBy == '') { - $groupBy = $io->ask( + $groupBy = $this->getIo()->ask( $this->trans('commands.generate.plugin.migrate.source.questions.group-by'), false ); @@ -245,15 +238,15 @@ class PluginMigrateSourceCommand extends Command if (!$fields) { $fields = []; while (true) { - $id = $io->ask( - $this->trans('commands.generate.plugin.migrate.source.questions.fields.id'), + $id = $this->getIo()->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.id'), false ); if (!$id) { break; } - $description = $io->ask( - $this->trans('commands.generate.plugin.migrate.source.questions.fields.description'), + $description = $this->getIo()->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.description'), $id ); $fields[] = [