use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
use Drupal\Core\Config\CachedStorage;
use Drupal\Core\Config\ConfigFactory;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
class OverrideCommand extends Command
{
- use CommandTrait;
-
/**
* @var CachedStorage
*/
InputArgument::REQUIRED,
$this->trans('commands.config.override.arguments.name')
)
- ->addArgument('key', InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.key'))
- ->addArgument('value', InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.value'));
+ ->addArgument(
+ 'key',
+ InputArgument::REQUIRED,
+ $this->trans('commands.config.override.arguments.key')
+ )
+ ->addArgument(
+ 'value',
+ InputArgument::REQUIRED,
+ $this->trans('commands.config.override.arguments.value')
+ )
+ ->setAliases(['co']);
}
/**
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
$name = $input->getArgument('name');
$names = $this->configFactory->listAll();
if ($name) {
if (!in_array($name, $names)) {
- $io->warning(
+ $this->getIo()->warning(
sprintf(
$this->trans('commands.config.override.messages.invalid-name'),
$name
}
}
if (!$name) {
- $name = $io->choiceNoList(
+ $name = $this->getIo()->choiceNoList(
$this->trans('commands.config.override.questions.name'),
$names
);
if ($this->configStorage->exists($name)) {
$configuration = $this->configStorage->read($name);
}
- $key = $io->choiceNoList(
+ $key = $this->getIo()->choiceNoList(
$this->trans('commands.config.override.questions.key'),
array_keys($configuration)
);
}
$value = $input->getArgument('value');
if (!$value) {
- $value = $io->ask(
+ $value = $this->getIo()->ask(
$this->trans('commands.config.override.questions.value')
);
$input->setArgument('value', $value);
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$configName = $input->getArgument('name');
$key = $input->getArgument('key');
$value = $input->getArgument('value');
$config = $this->configFactory->getEditable($configName);
- $configurationOverrideResult = $this->overrideConfiguration($config, $key, $value);
+ $configurationOverrideResult = $this->overrideConfiguration(
+ $config,
+ $key,
+ $value
+ );
$config->save();
- $io->info($this->trans('commands.config.override.messages.configuration'), false);
- $io->comment($configName);
+ $this->getIo()->info($this->trans('commands.config.override.messages.configuration'), false);
+ $this->getIo()->comment($configName);
$tableHeader = [
$this->trans('commands.config.override.messages.configuration-key'),
$this->trans('commands.config.override.messages.updated'),
];
$tableRows = $configurationOverrideResult;
- $io->table($tableHeader, $tableRows);
-
- $config->save();
+ $this->getIo()->table($tableHeader, $tableRows);
}