use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Exception\RuntimeException;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\CachedStorage;
use Drupal\Core\Config\ConfigFactory;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
class DeleteCommand extends Command
{
- use CommandTrait;
-
protected $allConfig = [];
/**
'name',
InputArgument::OPTIONAL,
$this->trans('commands.config.delete.arguments.name')
- );
+ )->setAliases(['cd']);
}
/**
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$type = $input->getArgument('type');
if (!$type) {
- $type = $io->choiceNoList(
+ $type = $this->getIo()->choiceNoList(
$this->trans('commands.config.delete.arguments.type'),
['active', 'staging'],
'active'
$name = $input->getArgument('name');
if (!$name) {
- $name = $io->choiceNoList(
+ $name = $this->getIo()->choiceNoList(
$this->trans('commands.config.delete.arguments.name'),
$this->getAllConfigNames(),
'all'
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$type = $input->getArgument('type');
if (!$type) {
- $io->error($this->trans('commands.config.delete.errors.type'));
+ $this->getIo()->error($this->trans('commands.config.delete.errors.type'));
return 1;
}
$name = $input->getArgument('name');
if (!$name) {
- $io->error($this->trans('commands.config.delete.errors.name'));
+ $this->getIo()->error($this->trans('commands.config.delete.errors.name'));
return 1;
}
$configStorage = ('active' === $type) ? $this->configStorage : $this->configStorageSync;
if (!$configStorage) {
- $io->error($this->trans('commands.config.delete.errors.config-storage'));
+ $this->getIo()->error($this->trans('commands.config.delete.errors.config-storage'));
return 1;
}
if ('all' === $name) {
- $io->commentBlock($this->trans('commands.config.delete.warnings.undo'));
- if ($io->confirm($this->trans('commands.config.delete.questions.sure'))) {
+ $this->getIo()->commentBlock($this->trans('commands.config.delete.warnings.undo'));
+ if ($this->getIo()->confirm($this->trans('commands.config.delete.questions.sure'))) {
if ($configStorage instanceof FileStorage) {
$configStorage->deleteAll();
} else {
}
}
- $io->success($this->trans('commands.config.delete.messages.all'));
+ $this->getIo()->success($this->trans('commands.config.delete.messages.all'));
return 0;
}
$this->removeConfig($name);
}
- $io->success(
+ $this->getIo()->success(
sprintf(
$this->trans('commands.config.delete.messages.deleted'),
$name
}
$message = sprintf($this->trans('commands.config.delete.errors.not-exists'), $name);
- $io->error($message);
+ $this->getIo()->error($message);
return 1;
}