X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginRulesActionCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginRulesActionCommand.php;h=473eb2ff10ec3d178a3842b22a28f1ca1f16a460;hp=43785e3d5b0f480c23c1c953b8edb2c393e97358;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console/src/Command/Generate/PluginRulesActionCommand.php b/vendor/drupal/console/src/Command/Generate/PluginRulesActionCommand.php index 43785e3d5..473eb2ff1 100644 --- a/vendor/drupal/console/src/Command/Generate/PluginRulesActionCommand.php +++ b/vendor/drupal/console/src/Command/Generate/PluginRulesActionCommand.php @@ -8,17 +8,15 @@ namespace Drupal\Console\Command\Generate; use Drupal\Console\Generator\PluginRulesActionGenerator; +use Drupal\Console\Utils\Validator; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Console\Command\Shared\ServicesTrait; use Drupal\Console\Command\Shared\ModuleTrait; -use Drupal\Console\Command\Shared\FormTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Extension\Manager; -use Drupal\Console\Core\Command\Shared\CommandTrait; use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Core\Utils\ChainQueue; @@ -31,9 +29,7 @@ class PluginRulesActionCommand extends Command { use ServicesTrait; use ModuleTrait; - use FormTrait; use ConfirmationTrait; - use CommandTrait; /** * @var Manager @@ -50,6 +46,11 @@ class PluginRulesActionCommand extends Command */ protected $stringConverter; + /** + * @var Validator + */ + protected $validator; + /** * @var ChainQueue */ @@ -62,17 +63,20 @@ class PluginRulesActionCommand extends Command * @param Manager $extensionManager * @param PluginRulesActionGenerator $generator * @param StringConverter $stringConverter + * @param Validator $validator * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, PluginRulesActionGenerator $generator, StringConverter $stringConverter, + Validator $validator, ChainQueue $chainQueue ) { $this->extensionManager = $extensionManager; $this->generator = $generator; $this->stringConverter = $stringConverter; + $this->validator = $validator; $this->chainQueue = $chainQueue; parent::__construct(); } @@ -83,7 +87,12 @@ class PluginRulesActionCommand extends Command ->setName('generate:plugin:rulesaction') ->setDescription($this->trans('commands.generate.plugin.rulesaction.description')) ->setHelp($this->trans('commands.generate.plugin.rulesaction.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, @@ -114,7 +123,8 @@ class PluginRulesActionCommand extends Command null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.rulesaction.options.context') - ); + ) + ->setAliases(['gpra']); } /** @@ -122,22 +132,28 @@ class PluginRulesActionCommand 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')); $label = $input->getOption('label'); $plugin_id = $input->getOption('plugin-id'); $type = $input->getOption('type'); $category = $input->getOption('category'); $context = $input->getOption('context'); - $this->generator->generate($module, $class_name, $label, $plugin_id, $category, $context, $type); + $this->generator->generate([ + 'module' => $module, + 'class_name' => $class_name, + 'label' => $label, + 'plugin_id' => $plugin_id, + 'category' => $category, + 'context' => $context, + 'type' => $type, + ]); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); @@ -146,22 +162,18 @@ class PluginRulesActionCommand extends Command 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); - } + $this->getModuleOption(); // --class option $class_name = $input->getOption('class'); if (!$class_name) { - $class_name = $io->ask( + $class_name = $this->getIo()->ask( $this->trans('commands.generate.plugin.rulesaction.options.class'), - 'DefaultAction' + 'DefaultAction', + function ($class_name) { + return $this->validator->validateClassName($class_name); + } ); $input->setOption('class', $class_name); } @@ -169,7 +181,7 @@ class PluginRulesActionCommand extends Command // --label option $label = $input->getOption('label'); if (!$label) { - $label = $io->ask( + $label = $this->getIo()->ask( $this->trans('commands.generate.plugin.rulesaction.options.label'), $this->stringConverter->camelCaseToHuman($class_name) ); @@ -179,7 +191,7 @@ class PluginRulesActionCommand extends Command // --plugin-id option $plugin_id = $input->getOption('plugin-id'); if (!$plugin_id) { - $plugin_id = $io->ask( + $plugin_id = $this->getIo()->ask( $this->trans('commands.generate.plugin.rulesaction.options.plugin-id'), $this->stringConverter->camelCaseToUnderscore($class_name) ); @@ -189,7 +201,7 @@ class PluginRulesActionCommand extends Command // --type option $type = $input->getOption('type'); if (!$type) { - $type = $io->ask( + $type = $this->getIo()->ask( $this->trans('commands.generate.plugin.rulesaction.options.type'), 'user' ); @@ -199,7 +211,7 @@ class PluginRulesActionCommand extends Command // --category option $category = $input->getOption('category'); if (!$category) { - $category = $io->ask( + $category = $this->getIo()->ask( $this->trans('commands.generate.plugin.rulesaction.options.category'), $this->stringConverter->camelCaseToUnderscore($class_name) ); @@ -209,7 +221,7 @@ class PluginRulesActionCommand extends Command // --context option $context = $input->getOption('context'); if (!$context) { - $context = $io->ask( + $context = $this->getIo()->ask( $this->trans('commands.generate.plugin.rulesaction.options.context'), $this->stringConverter->camelCaseToUnderscore($class_name) );