use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Config\CachedStorage;
use Drupal\Core\Config\ConfigFactory;
-use Symfony\Component\Console\Command\Command;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
+use Drupal\Console\Core\Command\Command;
use Drupal\Console\Core\Utils\ConfigurationManager;
class EditCommand extends Command
{
- use CommandTrait;
-
/**
* @var ConfigFactory
*/
'editor',
InputArgument::OPTIONAL,
$this->trans('commands.config.edit.arguments.editor')
- );
+ )
+ ->setAliases(['ced']);
}
/**
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$configName = $input->getArgument('config-name');
$editor = $input->getArgument('editor');
$config = $this->configFactory->getEditable($configName);
$fileSystem = new Filesystem();
if (!$configName) {
- $io->error($this->trans('commands.config.edit.messages.no-config'));
+ $this->getIo()->error($this->trans('commands.config.edit.messages.no-config'));
return 1;
}
$fileSystem->mkdir($temporaryDirectory);
$fileSystem->dumpFile($configFile, $this->getYamlConfig($configName));
} catch (IOExceptionInterface $e) {
- $io->error($this->trans('commands.config.edit.messages.no-directory').' '.$e->getPath());
+ $this->getIo()->error($this->trans('commands.config.edit.messages.no-directory').' '.$e->getPath());
return 1;
}
}
if (!$process->isSuccessful()) {
- $io->error($process->getErrorOutput());
+ $this->getIo()->error($process->getErrorOutput());
return 1;
}
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$configName = $input->getArgument('config-name');
if (!$configName) {
$configNames = $this->configFactory->listAll();
- $configName = $io->choice(
- 'Choose a configuration',
+ $configName = $this->getIo()->choice(
+ $this->trans('commands.config.edit.messages.choose-configuration'),
$configNames
);
protected function getEditor()
{
$config = $this->configurationManager->getConfiguration();
- $editor = $config->get('application.editor', 'vi');
+ $editor = $config->get('application.editor', '');
if ($editor != '') {
return trim($editor);