X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginImageEffectCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FPluginImageEffectCommand.php;h=50c8282d39a94832f4cd08ee724953e0c0914c6b;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=1a0fc1ce4c4016b30abb83399df9a9006e8ce43b;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/drupal/console/src/Command/Generate/PluginImageEffectCommand.php b/vendor/drupal/console/src/Command/Generate/PluginImageEffectCommand.php index 1a0fc1ce4..50c8282d3 100644 --- a/vendor/drupal/console/src/Command/Generate/PluginImageEffectCommand.php +++ b/vendor/drupal/console/src/Command/Generate/PluginImageEffectCommand.php @@ -7,16 +7,15 @@ namespace Drupal\Console\Command\Generate; +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\Generator\PluginImageEffectGenerator; use Drupal\Console\Command\Shared\ModuleTrait; 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; @@ -29,7 +28,6 @@ class PluginImageEffectCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; /** * @var Manager @@ -46,6 +44,11 @@ class PluginImageEffectCommand extends Command */ protected $stringConverter; + /** + * @var Validator + */ + protected $validator; + /** * @var ChainQueue */ @@ -58,17 +61,20 @@ class PluginImageEffectCommand extends Command * @param Manager $extensionManager * @param PluginImageEffectGenerator $generator * @param StringConverter $stringConverter + * @param Validator $validator * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, PluginImageEffectGenerator $generator, StringConverter $stringConverter, + Validator $validator, ChainQueue $chainQueue ) { $this->extensionManager = $extensionManager; $this->generator = $generator; $this->stringConverter = $stringConverter; + $this->validator = $validator; $this->chainQueue = $chainQueue; parent::__construct(); } @@ -79,7 +85,12 @@ class PluginImageEffectCommand extends Command ->setName('generate:plugin:imageeffect') ->setDescription($this->trans('commands.generate.plugin.imageeffect.description')) ->setHelp($this->trans('commands.generate.plugin.imageeffect.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, @@ -103,7 +114,8 @@ class PluginImageEffectCommand extends Command null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.imageeffect.options.description') - ); + ) + ->setAliases(['gpie']); } /** @@ -111,42 +123,42 @@ class PluginImageEffectCommand 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'); $description = $input->getOption('description'); - $this->generator->generate($module, $class_name, $label, $plugin_id, $description); + $this->generator->generate([ + 'module' => $module, + 'class_name' => $class_name, + 'label' => $label, + 'plugin_id' => $plugin_id, + 'description' => $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); - } + $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.imageeffect.questions.class'), - 'DefaultImageEffect' + 'DefaultImageEffect', + function ($class_name) { + return $this->validator->validateClassName($class_name); + } ); $input->setOption('class', $class_name); } @@ -154,7 +166,7 @@ class PluginImageEffectCommand extends Command // --label option $label = $input->getOption('label'); if (!$label) { - $label = $io->ask( + $label = $this->getIo()->ask( $this->trans('commands.generate.plugin.imageeffect.questions.label'), $this->stringConverter->camelCaseToHuman($class_name) ); @@ -164,7 +176,7 @@ class PluginImageEffectCommand 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.imageeffect.questions.plugin-id'), $this->stringConverter->camelCaseToUnderscore($class_name) ); @@ -174,9 +186,9 @@ class PluginImageEffectCommand extends Command // --description option $description = $input->getOption('description'); if (!$description) { - $description = $io->ask( + $description = $this->getIo()->ask( $this->trans('commands.generate.plugin.imageeffect.questions.description'), - 'My Image Effect' + $this->trans('commands.generate.plugin.imageeffect.suggestions.my-image-effect') ); $input->setOption('description', $description); }