Skip to content

Commit

Permalink
[console] Resolve missing module variable. Fix #3670 (#3671)
Browse files Browse the repository at this point in the history
* Replace code getting module from the input with ModuleTrait method

* Add the validator service for the commands, which receiving module as a parameter

* Fix missing  variable presented in PR 3653
  • Loading branch information
LOBsTerr authored and jmolivas committed Jan 10, 2018
1 parent 5aef231 commit 39c432d
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/Command/Config/ExportSingleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
}

// --module option
$this->moduleFromInput($io, $input);

$module = $input->getOption('module');
$module = $this->moduleFromInput($io, $input);
if ($module) {
$optionalConfig = $input->getOption('optional');
if (!$optionalConfig) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/CacheContextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

// --cache_context option
$cache_context = $input->getOption('cache-context');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/ControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

// --class option
$class = $input->getOption('class');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/EventSubscriberCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

// --service-name option
$name = $input->getOption('name');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/FormCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

// --class option
$className = $input->getOption('class');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginCKEditorButtonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

// --class option
$class_name = $input->getOption('class');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginMigrateProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// 'module-name' option.
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

// 'class-name' option
$class = $input->getOption('class');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginMigrateSourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// 'module-name' option.
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

$class = $input->getOption('class');
if (!$class) {
Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/RouteSubscriberCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,11 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

// --name option
$name = $input->getOption('name');
if (!$name) {
$module = $input->getOption('module');
$name = $io->ask(
$this->trans('commands.generate.routesubscriber.questions.name'),
$module.'.route_subscriber'
Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/ServiceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,11 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

//--name option
$name = $input->getOption('name');
if (!$name) {
$module = $input->getOption('module');
$name = $io->ask(
$this->trans('commands.generate.service.questions.service-name'),
$module.'.default'
Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/TwigExtensionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ protected function interact(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

// --name option
$name = $input->getOption('name');
if (!$name) {
$module = $input->getOption('module');
$name = $io->ask(
$this->trans('commands.generate.twig.extension.questions.name'),
$module.'.twig.extension'
Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,8 @@ protected function interact(InputInterface $input, OutputInterface $output)
$this->site->loadLegacyFile('/core/includes/schema.inc');

// --module option
$this->moduleFromInput($io, $input);
$module = $this->moduleFromInput($io, $input);

$module = $input->getOption('module');
$lastUpdateSchema = $this->getLastUpdate($module);
$nextUpdateSchema = $lastUpdateSchema ? ($lastUpdateSchema + 1): 8001;

Expand Down
5 changes: 5 additions & 0 deletions src/Command/Shared/ModuleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public function moduleRequirement(array $module, DrupalStyle $io)
* Console interface.
* @param InputInterface $input
* Input interface.
*
* @return mixed|string
* Module name.
* @throws \Exception
* When module is not found.
*/
Expand All @@ -118,5 +121,7 @@ public function moduleFromInput(DrupalStyle $io, InputInterface $input)
);
}
}

return $module;
}
}

0 comments on commit 39c432d

Please sign in to comment.