X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginViewsFieldCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginViewsFieldCommand.php;h=c0962a2b77c24bead738fcad6afeeb81174c1e76;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Command/Generate/PluginViewsFieldCommand.php b/vendor/drupal/console/src/Command/Generate/PluginViewsFieldCommand.php new file mode 100644 index 000000000..c0962a2b7 --- /dev/null +++ b/vendor/drupal/console/src/Command/Generate/PluginViewsFieldCommand.php @@ -0,0 +1,182 @@ +extensionManager = $extensionManager; + $this->generator = $generator; + $this->site = $site; + $this->stringConverter = $stringConverter; + $this->chainQueue = $chainQueue; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('generate:plugin:views:field') + ->setDescription($this->trans('commands.generate.plugin.views.field.description')) + ->setHelp($this->trans('commands.generate.plugin.views.field.help')) + ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption( + 'class', + '', + InputOption::VALUE_REQUIRED, + $this->trans('commands.generate.plugin.views.field.options.class') + ) + ->addOption( + 'title', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.views.field.options.title') + ) + ->addOption( + 'description', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.views.field.options.description') + ); + } + + /** + * {@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; + } + + $module = $input->getOption('module'); + $class_name = $input->getOption('class'); + $class_machine_name = $this->stringConverter->camelCaseToUnderscore($class_name); + $title = $input->getOption('title'); + $description = $input->getOption('description'); + + $this->generator->generate($module, $class_machine_name, $class_name, $title, $description); + + $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + } + + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // --module option + $module = $input->getOption('module'); + if (!$module) { + // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion + $module = $this->moduleQuestion($io); + $input->setOption('module', $module); + } + + // --class option + $class_name = $input->getOption('class'); + if (!$class_name) { + $class_name = $io->ask( + $this->trans('commands.generate.plugin.views.field.questions.class'), + 'CustomViewsField' + ); + } + $input->setOption('class', $class_name); + + // --title option + $title = $input->getOption('title'); + if (!$title) { + $title = $io->ask( + $this->trans('commands.generate.plugin.views.field.questions.title'), + $this->stringConverter->camelCaseToHuman($class_name) + ); + $input->setOption('title', $title); + } + + // --description option + $description = $input->getOption('description'); + if (!$description) { + $description = $io->ask( + $this->trans('commands.generate.plugin.views.field.questions.description'), + $this->trans('commands.generate.plugin.views.field.questions.description_default') + ); + $input->setOption('description', $description); + } + } + + protected function createGenerator() + { + return new PluginViewsFieldGenerator(); + } +}