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\KeyValueStore\KeyValueFactoryInterface;
use Drupal\Core\State\StateInterface;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Component\Serialization\Yaml;
/**
*/
class OverrideCommand extends Command
{
- use CommandTrait;
-
/**
* @var StateInterface
*/
'value',
InputArgument::OPTIONAL,
$this->trans('commands.state.override.arguments.value')
- );
+ )->setAliases(['sto']);
}
/**
* {@inheritdoc}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
$key = $input->getArgument('key');
$value = $input->getArgument('value');
if (!$key) {
$names = array_keys($this->keyValue->get('state')->getAll());
- $key = $io->choiceNoList(
+ $key = $this->getIo()->choiceNoList(
$this->trans('commands.state.override.arguments.key'),
$names
);
$input->setArgument('key', $key);
}
if (!$value) {
- $value = $io->ask(
+ $value = $this->getIo()->ask(
$this->trans('commands.state.override.arguments.value')
);
$input->setArgument('value', $value);
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
$key = $input->getArgument('key');
$value = $input->getArgument('value');
if (!$key) {
- $io->error($this->trans('commands.state.override.errors.no-key'));
+ $this->getIo()->error($this->trans('commands.state.override.errors.no-key'));
return 1;
}
if (!$value) {
- $io->error($this->trans('commands.state.override.errors.no-value'));
+ $this->getIo()->error($this->trans('commands.state.override.errors.no-value'));
return 1;
}
$tableRows[] = [$key, $originalValue, $overrideValue];
- $io->table(
+ $this->getIo()->table(
$tableHeaders,
$tableRows
);