X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginTypeYamlCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginTypeYamlCommand.php;h=6295481f92fa79e28ddaf0af5b12750bfc579dfe;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Command/Generate/PluginTypeYamlCommand.php b/vendor/drupal/console/src/Command/Generate/PluginTypeYamlCommand.php new file mode 100644 index 000000000..6295481f9 --- /dev/null +++ b/vendor/drupal/console/src/Command/Generate/PluginTypeYamlCommand.php @@ -0,0 +1,153 @@ +extensionManager = $extensionManager; + $this->generator = $generator; + $this->stringConverter = $stringConverter; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('generate:plugin:type:yaml') + ->setDescription($this->trans('commands.generate.plugin.type.yaml.description')) + ->setHelp($this->trans('commands.generate.plugin.type.yaml.help')) + ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption( + 'class', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.type.yaml.options.class') + ) + ->addOption( + 'plugin-name', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.type.yaml.options.plugin-name') + ) + ->addOption( + 'plugin-file-name', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.type.yaml.options.plugin-file-name') + ); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $module = $input->getOption('module'); + $class_name = $input->getOption('class'); + $plugin_name = $input->getOption('plugin-name'); + $plugin_file_name = $input->getOption('plugin-file-name'); + + $this->generator->generate($module, $class_name, $plugin_name, $plugin_file_name); + } + + 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.type.yaml.options.class'), + 'ExamplePlugin' + ); + $input->setOption('class', $class_name); + } + + // --plugin-name option + $plugin_name = $input->getOption('plugin-name'); + if (!$plugin_name) { + $plugin_name = $io->ask( + $this->trans('commands.generate.plugin.type.yaml.options.plugin-name'), + $this->stringConverter->camelCaseToUnderscore($class_name) + ); + $input->setOption('plugin-name', $plugin_name); + } + + // --plugin-file-name option + $plugin_file_name = $input->getOption('plugin-file-name'); + if (!$plugin_file_name) { + $plugin_file_name = $io->ask( + $this->trans('commands.generate.plugin.type.yaml.options.plugin-file-name'), + strtr($plugin_name, '_-', '..') + ); + $input->setOption('plugin-file-name', $plugin_file_name); + } + } +}