setName('config:override')
->setDescription($this->trans('commands.config.override.description'))
->addArgument('config-name', InputArgument::REQUIRED,
$this->trans('commands.config.override.arguments.config-name'))
->addArgument('key', InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.key'))
->addArgument('value', InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.value'));
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$table = $this->getHelperSet()->get('table');
$configName = $input->getArgument('config-name');
$key = $input->getArgument('key');
$value = $input->getArgument('value');
$config = $this->getConfigFactory()->getEditable($configName);
$configurationOverrideResult = $this->overrideConfiguration($config, $key, $value);
$config->save();
$output->writeln(sprintf(
' %s: %s',
$this->trans('commands.config.override.messages.configuration'),
$configName
));
$table->setHeaders(
[
$this->trans('commands.config.override.messages.configuration-key'),
$this->trans('commands.config.override.messages.original'),
$this->trans('commands.config.override.messages.updated'),
]);
$table->setlayout($table::LAYOUT_COMPACT);
$table->setRows($configurationOverrideResult);
$table->render($output);
$config->save();
}
protected function overrideConfiguration($config, $key, $value)
{
$result[] = [
'configuration' => $key,
'original' => $config->get($key),
'updated' => $value,
];
$config->set($key, $value);
return $result;
}
}