Skip to content

Commit

Permalink
[console] Apply PSR-2 code style. (#3161)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Feb 5, 2017
1 parent e03ab42 commit 7b1d370
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 225 deletions.
6 changes: 3 additions & 3 deletions src/Command/Config/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class DeleteCommand extends Command
/**
* DeleteCommand constructor.
*
* @param ConfigFactory $configFactory
* @param CachedStorage $configStorage
* @param StorageInterface $configStorageSync
* @param ConfigFactory $configFactory
* @param CachedStorage $configStorage
* @param StorageInterface $configStorageSync
*/
public function __construct(
ConfigFactory $configFactory,
Expand Down
5 changes: 2 additions & 3 deletions src/Command/Config/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

if ($this->configImport($io, $storage_comparer)) {
$io->success($this->trans('commands.config.import.messages.imported'));
}
else {
} else {
return 1;
}
}
Expand All @@ -129,7 +128,7 @@ private function configImport(DrupalStyle $io, StorageComparer $storage_comparer
try {
$io->info($this->trans('commands.config.import.messages.importing'));
$config_importer->import();
return TRUE;
return true;
} catch (ConfigImporterException $e) {
$message = 'The import failed due for the following reasons:' . "\n";
$message .= implode("\n", $config_importer->getErrors());
Expand Down
19 changes: 9 additions & 10 deletions src/Command/Create/NodesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ protected function configure()
InputOption::VALUE_OPTIONAL,
$this->trans('commands.create.nodes.options.time-range')
)
->addOption(
'language',
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.create.nodes.options.language')
);
->addOption(
'language',
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.create.nodes.options.language')
);
}

/**
Expand Down Expand Up @@ -168,13 +168,12 @@ function ($contentType) use ($bundles) {
// If no language option or invalid language code in option.
if (!$language || !array_key_exists($language, $language_list)) {
$language = $io->choice(
$this->trans('commands.create.nodes.questions.language'),
$language_list
$this->trans('commands.create.nodes.questions.language'),
$language_list
);
}
$input->setOption('language', $language);
}
else {
} else {
// If 'language' module is not enabled.
$input->setOption('language', LanguageInterface::LANGCODE_NOT_SPECIFIED);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Cron/ExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 1;
}

if ( $modules === NULL || in_array('all', $modules)) {
if ($modules === null || in_array('all', $modules)) {
$modules = $this->moduleHandler->getImplementations('cron');
}

Expand Down
230 changes: 115 additions & 115 deletions src/Command/Generate/CacheContextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,148 +23,148 @@

class CacheContextCommand extends Command
{
use ModuleTrait;
use ConfirmationTrait;
use ContainerAwareCommandTrait;
use ServicesTrait;
use ModuleTrait;
use ConfirmationTrait;
use ContainerAwareCommandTrait;
use ServicesTrait;

/**
/**
* @var CacheContextGenerator
*/
protected $generator;
protected $generator;

/**
/**
* @var ChainQueue
*/
protected $chainQueue;
protected $chainQueue;

/**
/**
* @var Manager
*/
protected $extensionManager;
protected $extensionManager;

/**
/**
* @var StringConverter
*/
protected $stringConverter;
protected $stringConverter;

/**
/**
* CacheContextCommand constructor.
*
* @param CacheContextGenerator $generator
* @param ChainQueue $chainQueue
* @param Manager $extensionManager
* @param StringConverter $stringConverter
* @param CacheContextGenerator $generator
* @param ChainQueue $chainQueue
* @param Manager $extensionManager
* @param StringConverter $stringConverter
*/
public function __construct(
CacheContextGenerator $generator,
ChainQueue $chainQueue,
Manager $extensionManager,
StringConverter $stringConverter
) {
$this->generator = $generator;
$this->chainQueue = $chainQueue;
$this->extensionManager = $extensionManager;
$this->stringConverter = $stringConverter;
parent::__construct();
}

/**
public function __construct(
CacheContextGenerator $generator,
ChainQueue $chainQueue,
Manager $extensionManager,
StringConverter $stringConverter
) {
$this->generator = $generator;
$this->chainQueue = $chainQueue;
$this->extensionManager = $extensionManager;
$this->stringConverter = $stringConverter;
parent::__construct();
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('generate:cache:context')
->setDescription($this->trans('commands.generate.cache.context.description'))
->setHelp($this->trans('commands.generate.cache.context.description'))
->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module'))
->addOption(
'cache_context',
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.generate.cache.context.questions.name')
)
->addOption(
'class',
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.generate.cache.context.questions.class')
)
->addOption(
'services',
null,
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
$this->trans('commands.common.options.services')
);
}

/**
protected function configure()
{
$this
->setName('generate:cache:context')
->setDescription($this->trans('commands.generate.cache.context.description'))
->setHelp($this->trans('commands.generate.cache.context.description'))
->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module'))
->addOption(
'cache_context',
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.generate.cache.context.questions.name')
)
->addOption(
'class',
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.generate.cache.context.questions.class')
)
->addOption(
'services',
null,
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
$this->trans('commands.common.options.services')
);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);

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

$module = $input->getOption('module');
$cache_context = $input->getOption('cache_context');
$class = $input->getOption('class');
$services = $input->getOption('services');
$module = $input->getOption('module');
$cache_context = $input->getOption('cache_context');
$class = $input->getOption('class');
$services = $input->getOption('services');

// @see Drupal\Console\Command\Shared\ServicesTrait::buildServices
$buildServices = $this->buildServices($services);
// @see Drupal\Console\Command\Shared\ServicesTrait::buildServices
$buildServices = $this->buildServices($services);

$this->generator->generate($module, $cache_context, $class, $buildServices);
$this->generator->generate($module, $cache_context, $class, $buildServices);

$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
}
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
}

/**
/**
* {@inheritdoc}
*/
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);
}

// --cache_context option
$cache_context = $input->getOption('cache_context');
if (!$cache_context) {
$cache_context = $io->ask(
$this->trans('commands.generate.cache.context.questions.name'),
sprintf('%s', $module)
);
$input->setOption('cache_context', $cache_context);
}

// --class option
$class = $input->getOption('class');
if (!$class) {
$class = $io->ask(
$this->trans('commands.generate.cache.context.questions.class'),
'DefaultCacheContext'
);
$input->setOption('class', $class);
}

// --services option
$services = $input->getOption('services');
if (!$services) {
// @see Drupal\Console\Command\Shared\ServicesTrait::servicesQuestion
$services = $this->servicesQuestion($io);
$input->setOption('services', $services);
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);
}

// --cache_context option
$cache_context = $input->getOption('cache_context');
if (!$cache_context) {
$cache_context = $io->ask(
$this->trans('commands.generate.cache.context.questions.name'),
sprintf('%s', $module)
);
$input->setOption('cache_context', $cache_context);
}

// --class option
$class = $input->getOption('class');
if (!$class) {
$class = $io->ask(
$this->trans('commands.generate.cache.context.questions.class'),
'DefaultCacheContext'
);
$input->setOption('class', $class);
}

// --services option
$services = $input->getOption('services');
if (!$services) {
// @see Drupal\Console\Command\Shared\ServicesTrait::servicesQuestion
$services = $this->servicesQuestion($io);
$input->setOption('services', $services);
}
}
}
}
8 changes: 4 additions & 4 deletions src/Command/Generate/PluginMigrateProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class PluginMigrateProcessCommand extends Command
/**
* PluginBlockCommand constructor.
*
* @param PluginMigrateProcessGenerator $generator
* @param ChainQueue $chainQueue
* @param Manager $extensionManager
* @param StringConverter $stringConverter
* @param PluginMigrateProcessGenerator $generator
* @param ChainQueue $chainQueue
* @param Manager $extensionManager
* @param StringConverter $stringConverter
*/
public function __construct(
PluginMigrateProcessGenerator $generator,
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 @@ -57,7 +57,7 @@ class UpdateCommand extends Command
*
* @param Manager $extensionManager
* @param UpdateGenerator $generator
* @param Site $site
* @param Site $site
* @param ChainQueue $chainQueue
*/
public function __construct(
Expand Down
Loading

0 comments on commit 7b1d370

Please sign in to comment.