Skip to content

Commit

Permalink
Add support of --yes (confirmation) parameter for the command, which …
Browse files Browse the repository at this point in the history
…generate the code and files (#3656)
  • Loading branch information
LOBsTerr authored and jmolivas committed Jan 8, 2018
1 parent b586b25 commit 42c18c3
Show file tree
Hide file tree
Showing 36 changed files with 42 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/Command/Generate/AuthenticationProviderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/BreakPointCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

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 @@ -119,7 +119,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/CommandCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$interact = $input->getOption('interact');
$containerAware = $input->getOption('container-aware');
$services = $input->getOption('services');
$yes = $input->hasOption('yes')?$input->getOption('yes'):false;

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io, $yes)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/ControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$yes = $input->hasOption('yes')?$input->getOption('yes'):false;

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io, $yes)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/EntityBundleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

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 @@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

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

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/JsTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$yes = $input->hasOption('yes') ? $input->getOption('yes') : false;

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io, $yes)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/ModuleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$yes = $input->hasOption('yes')?$input->getOption('yes'):false;

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io, $yes)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/ModuleFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io, $yes)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginBlockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

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 @@ -129,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginConditionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginFieldCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginFieldFormatterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginFieldTypeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginFieldWidgetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginImageEffectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginImageFormatterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginMailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

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 @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

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 @@ -159,7 +159,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginRestResourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginRulesActionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PluginSkeletonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$plugins = $this->getPlugins();

// @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

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

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/PostUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Command/Generate/ProfileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);

if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}


// Get the profile path and define a profile path if it is null
// Check that it is an absolute path or otherwise create an absolute path using appRoot
$profile_path = $input->getOption('profile-path');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/RouteSubscriberCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($output)) {
if (!$this->confirmGeneration($output, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/ServiceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/ThemeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/TwigExtensionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Generate/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io = new DrupalStyle($input, $output);

// @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io)) {
if (!$this->confirmGeneration($io, $input)) {
return 1;
}

Expand Down
10 changes: 7 additions & 3 deletions src/Command/Shared/ConfirmationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Drupal\Console\Command\Shared;

use Drupal\Console\Core\Style\DrupalStyle;
use Symfony\Component\Console\Input\InputInterface;

/**
* Class ConfirmationTrait
Expand All @@ -17,13 +18,16 @@
trait ConfirmationTrait
{
/**
* @param DrupalStyle $io
* @param bool $yes
* @param DrupalStyle $io
* Console interface.
* @param InputInterface $input
* Input interface.
*
* @return bool
*/
public function confirmGeneration(DrupalStyle $io, $yes = false)
public function confirmGeneration(DrupalStyle $io, InputInterface $input)
{
$yes = $input->hasOption('yes') ? $input->getOption('yes') : false;
if ($yes) {
return $yes;
}
Expand Down

0 comments on commit 42c18c3

Please sign in to comment.