Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/services/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ services:
arguments: ['@config.storage', '@config.manager']
tags:
- { name: drupal.command }
console.config_override:
class: Drupal\Console\Command\Config\OverrideCommand
console.config_set:
class: Drupal\Console\Command\Config\SetCommand
arguments: ['@config.storage', '@config.factory']
tags:
- { name: drupal.command }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @file
* Contains \Drupal\Console\Command\Config\OverrideCommand.
* Contains \Drupal\Console\Command\Config\SetCommand.
*/

namespace Drupal\Console\Command\Config;
Expand All @@ -15,7 +15,7 @@
use Drupal\Core\Config\CachedStorage;
use Drupal\Core\Config\ConfigFactory;

class OverrideCommand extends Command
class SetCommand extends Command
{
/**
* @var CachedStorage
Expand All @@ -28,7 +28,7 @@ class OverrideCommand extends Command
protected $configFactory;

/**
* OverrideCommand constructor.
* SetCommand constructor.
*
* @param CachedStorage $configStorage
* @param ConfigFactory $configFactory
Expand All @@ -45,24 +45,24 @@ public function __construct(
protected function configure()
{
$this
->setName('config:override')
->setDescription($this->trans('commands.config.override.description'))
->setName('config:set')
->setDescription($this->trans('commands.config.set.description'))
->addArgument(
'name',
InputArgument::REQUIRED,
$this->trans('commands.config.override.arguments.name')
$this->trans('commands.config.set.arguments.name')
)
->addOption(
'key',
null,
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
$this->trans('commands.config.override.options.key')
$this->trans('commands.config.set.options.key')
)
->addOption(
'value',
null,
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
$this->trans('commands.config.override.options.value')
$this->trans('commands.config.set.options.value')
)
->setAliases(['co']);
}
Expand All @@ -78,7 +78,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
if (!in_array($name, $names)) {
$this->getIo()->warning(
sprintf(
$this->trans('commands.config.override.messages.invalid-name'),
$this->trans('commands.config.set.messages.invalid-name'),
$name
)
);
Expand All @@ -87,7 +87,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
}
if (!$name) {
$name = $this->getIo()->choiceNoList(
$this->trans('commands.config.override.questions.name'),
$this->trans('commands.config.set.questions.name'),
$names
);
$input->setArgument('name', $name);
Expand All @@ -96,7 +96,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
if (!$key) {
if (!$this->configStorage->exists($name)) {
$this->getIo()->newLine();
$this->getIo()->errorLite($this->trans('commands.config.override.messages.invalid-config-file'));
$this->getIo()->errorLite($this->trans('commands.config.set.messages.invalid-config-file'));
$this->getIo()->newLine();
return 0;
}
Expand Down Expand Up @@ -134,7 +134,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$configurationOverrideResult = [];
foreach ($keys as $index => $key) {
$result = $this->overrideConfiguration(
$result = $this->setConfiguration(
$config,
$key,
$values[$index]
Expand All @@ -144,20 +144,20 @@ protected function execute(InputInterface $input, OutputInterface $output)

$config->save();

$this->getIo()->info($this->trans('commands.config.override.messages.configuration'), false);
$this->getIo()->info($this->trans('commands.config.set.messages.configuration'), false);
$this->getIo()->comment($configName);

$tableHeader = [
$this->trans('commands.config.override.messages.configuration-key'),
$this->trans('commands.config.override.messages.original'),
$this->trans('commands.config.override.messages.updated'),
$this->trans('commands.config.set.messages.configuration-key'),
$this->trans('commands.config.set.messages.original'),
$this->trans('commands.config.set.messages.updated'),
];
$tableRows = $configurationOverrideResult;
$this->getIo()->table($tableHeader, $tableRows);
}


protected function overrideConfiguration($config, $key, $value)
protected function setConfiguration($config, $key, $value)
{
$result[] = [
'configuration' => $key,
Expand All @@ -180,7 +180,7 @@ protected function overrideConfiguration($config, $key, $value)
private function getKeysFromConfig($configuration, $key = null)
{
$choiceKey = $this->getIo()->choiceNoList(
$this->trans('commands.config.override.questions.key'),
$this->trans('commands.config.set.questions.key'),
array_keys($configuration)
);

Expand Down