Skip to content

Commit

Permalink
[console] Apply PSR-2 code style. (#3652)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Jan 7, 2018
1 parent 5076f18 commit e11c3ba
Show file tree
Hide file tree
Showing 23 changed files with 204 additions and 217 deletions.
5 changes: 0 additions & 5 deletions config.yml

This file was deleted.

4 changes: 3 additions & 1 deletion src/Bootstrap/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ public function boot()
];

if (in_array($e->getCode(), $notifyErrorCodes)) {
/** @var \Drupal\Console\Core\Utils\MessageManager $messageManager */
/**
* @var \Drupal\Console\Core\Utils\MessageManager $messageManager
*/
$messageManager = $container->get('console.message_manager');
$messageManager->error(
$e->getMessage(),
Expand Down
11 changes: 8 additions & 3 deletions src/Bootstrap/DrupalKernelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public function discoverServiceProviders()
$this->discoverDrupalConsoleServiceProviders();
}

public function getContainerKey() {
public function getContainerKey()
{
return hash("sha256", $this->getContainerCacheKey());
}

Expand Down Expand Up @@ -97,7 +98,9 @@ protected function addDrupalConsoleServices($root)
$root. DRUPAL_CONSOLE . 'uninstall.services.yml',
$root. DRUPAL_CONSOLE . 'services.yml'
],
function ($file) { return file_exists($file); }
function ($file) {
return file_exists($file);
}
);

$this->addDrupalServiceFiles($servicesFiles);
Expand Down Expand Up @@ -130,7 +133,9 @@ protected function addDrupalConsoleExtendedServices($root)
$root . DRUPAL_CONSOLE . 'extend.console.services.yml',
$root . DRUPAL_CONSOLE . 'extend.console.uninstall.services.yml',
],
function ($file) { return file_exists($file); }
function ($file) {
return file_exists($file);
}
);

$this->addDrupalServiceFiles($servicesFiles);
Expand Down
57 changes: 28 additions & 29 deletions src/Command/Config/ExportContentTypeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class ExportContentTypeCommand extends Command
* @param Manager $extensionManager
*/
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
CachedStorage $configStorage,
Manager $extensionManager
EntityTypeManagerInterface $entityTypeManager,
CachedStorage $configStorage,
Manager $extensionManager
) {
$this->entityTypeManager = $entityTypeManager;
$this->configStorage = $configStorage;
Expand All @@ -66,30 +66,30 @@ public function __construct(
protected function configure()
{
$this
->setName('config:export:content:type')
->setDescription($this->trans('commands.config.export.content.type.description'))
->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module'))
->addArgument(
'content-type',
InputArgument::REQUIRED,
$this->trans('commands.config.export.content.type.arguments.content-type')
)->addOption(
'optional-config',
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.config.export.content.type.options.optional-config')
)->addOption(
'remove-uuid',
null,
InputOption::VALUE_NONE,
$this->trans('commands.config.export.content.type.options.remove-uuid')
)->addOption(
'remove-config-hash',
null,
InputOption::VALUE_NONE,
$this->trans('commands.config.export.content.type.options.remove-config-hash')
)
->setAliases(['cect']);
->setName('config:export:content:type')
->setDescription($this->trans('commands.config.export.content.type.description'))
->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module'))
->addArgument(
'content-type',
InputArgument::REQUIRED,
$this->trans('commands.config.export.content.type.arguments.content-type')
)->addOption(
'optional-config',
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.config.export.content.type.options.optional-config')
)->addOption(
'remove-uuid',
null,
InputOption::VALUE_NONE,
$this->trans('commands.config.export.content.type.options.remove-uuid')
)->addOption(
'remove-config-hash',
null,
InputOption::VALUE_NONE,
$this->trans('commands.config.export.content.type.options.remove-config-hash')
)
->setAliases(['cect']);

$this->configExport = [];
}
Expand Down Expand Up @@ -149,7 +149,6 @@ protected function interact(InputInterface $input, OutputInterface $output)
);
$input->setOption('remove-config-hash', $removeHash);
}

}

/**
Expand All @@ -171,7 +170,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$contentTypeNameConfig = $this->getConfiguration($contentTypeName, $removeUuid, $removeHash);

if (empty($contentTypeNameConfig)) {
throw new InvalidOptionException(sprintf('The content type %s does not exist.', $contentType));
throw new InvalidOptionException(sprintf('The content type %s does not exist.', $contentType));
}

$this->configExport[$contentTypeName] = ['data' => $contentTypeNameConfig, 'optional' => $optionalConfig];
Expand Down
25 changes: 12 additions & 13 deletions src/Command/Config/ExportSingleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ protected function interact(InputInterface $input, OutputInterface $output)

$module = $input->getOption('module');
if (!$module) {
// @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
$module = $this->moduleQuestion($io);
// @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
$module = $this->moduleQuestion($io);
}
$input->setOption('module', $module);

Expand Down Expand Up @@ -335,17 +335,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
protected function getLanguage()
{
$output = [];
// Get the language that be for default.
$default_id = $this->languageManager->getDefaultLanguage()->getId();
foreach ($this->languageManager->getLanguages() as $key => $value) {
if ($default_id == $key) {
$output[] = '';
}
else {
$output[] = 'language.' . $value->getId();
$output = [];
// Get the language that be for default.
$default_id = $this->languageManager->getDefaultLanguage()->getId();
foreach ($this->languageManager->getLanguages() as $key => $value) {
if ($default_id == $key) {
$output[] = '';
} else {
$output[] = 'language.' . $value->getId();
}
}
}
return $output;
return $output;
}
}
13 changes: 7 additions & 6 deletions src/Command/Config/OverrideCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ protected function configure()
$this->trans('commands.config.override.arguments.name')
)
->addArgument(
'key',
InputArgument::REQUIRED,
$this->trans('commands.config.override.arguments.key'))
'key',
InputArgument::REQUIRED,
$this->trans('commands.config.override.arguments.key')
)
->addArgument(
'value',
InputArgument::REQUIRED,
$this->trans('commands.config.override.arguments.value')
'value',
InputArgument::REQUIRED,
$this->trans('commands.config.override.arguments.value')
)
->setAliases(['co']);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Config/ValidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ protected function configure()
->setName('config:validate')
->setDescription($this->trans('commands.config.validate.description'))
->addArgument(
'name',
InputArgument::REQUIRED
'name',
InputArgument::REQUIRED
)->setAliases(['cv']);
}

Expand Down
1 change: 0 additions & 1 deletion src/Command/Create/CommentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
/**
* Class CommentsCommand
*
*
* @package Drupal\Console\Command\Generate
*
* @DrupalCommand(
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Database/RestoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
);
return 1;
}
if (strpos($file, '.sql.gz') !== FALSE) {
if (strpos($file, '.sql.gz') !== false) {
$catCommand = "gunzip -c %s | ";
} else {
$catCommand = "cat %s | ";
Expand Down
14 changes: 7 additions & 7 deletions src/Command/Debug/ConfigValidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ protected function configure()
->setName('debug:config:validate')
->setDescription($this->trans('commands.debug.config.validate.description'))
->addArgument(
'filepath',
InputArgument::REQUIRED
'filepath',
InputArgument::REQUIRED
)
->addArgument(
'schema-filepath',
InputArgument::REQUIRED
'schema-filepath',
InputArgument::REQUIRED
)
->addOption(
'schema-name',
'sch',
InputOption::VALUE_REQUIRED
'schema-name',
'sch',
InputOption::VALUE_REQUIRED
)->setAliases(['dcv']);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Command/Debug/ContainerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ private function getServiceList($tag)
return $services;
}

private function getServiceListByTag($tag) {
private function getServiceListByTag($tag)
{
$services = [];
$serviceIds = [];
$serviceDefinitions = $this->container->getDefinitions();
Expand Down
Loading

0 comments on commit e11c3ba

Please sign in to comment.