use Symfony\Component\Console\Input\InputOption;
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\ConfigManager;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Core\Config\ConfigImporterException;
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\FileStorage;
-use Drupal\Core\Config\StorageComparer;
+use Drupal\Core\Config\StorageComparerInterface;
class ImportCommand extends Command
{
- use CommandTrait;
-
/**
* @var CachedStorage
*/
null,
InputOption::VALUE_NONE,
$this->trans('commands.config.import.options.remove-files')
- );
+ )
+ ->addOption(
+ 'skip-uuid',
+ null,
+ InputOption::VALUE_NONE,
+ $this->trans('commands.config.import.options.skip-uuid')
+ )
+ ->setAliases(['ci']);
}
/**
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
$directory = $input->getOption('directory');
+ $skipUuid = $input->getOption('skip-uuid');
if ($directory) {
$configSyncDir = $directory;
$source_storage = new FileStorage($configSyncDir);
- $storage_comparer = new StorageComparer($source_storage, $this->configStorage, $this->configManager);
+ $storageComparer = '\Drupal\Core\Config\StorageComparer';
+ if ($skipUuid) {
+ $storageComparer = '\Drupal\Console\Override\StorageComparer';
+ }
+
+ $storage_comparer = new $storageComparer(
+ $source_storage,
+ $this->configStorage,
+ $this->configManager
+ );
if (!$storage_comparer->createChangelist()->hasChanges()) {
- $io->success($this->trans('commands.config.import.messages.nothing-to-do'));
+ $this->getIo()->success($this->trans('commands.config.import.messages.nothing-to-do'));
}
- if ($this->configImport($io, $storage_comparer)) {
- $io->success($this->trans('commands.config.import.messages.imported'));
+ if ($this->configImport($storage_comparer)) {
+ $this->getIo()->success($this->trans('commands.config.import.messages.imported'));
} else {
return 1;
}
}
- private function configImport(DrupalStyle $io, StorageComparer $storage_comparer)
+ private function configImport(StorageComparerInterface $storage_comparer)
{
$config_importer = new ConfigImporter(
$storage_comparer,
);
if ($config_importer->alreadyImporting()) {
- $io->success($this->trans('commands.config.import.messages.already-imported'));
+ $this->getIo()->success($this->trans('commands.config.import.messages.already-imported'));
} else {
try {
- $io->info($this->trans('commands.config.import.messages.importing'));
+ $this->getIo()->info($this->trans('commands.config.import.messages.importing'));
$config_importer->import();
return true;
} catch (ConfigImporterException $e) {
- $message = 'The import failed due to the following reasons:' . "\n";
- $message .= implode("\n", $config_importer->getErrors());
- $io->error(
+ $this->getIo()->error(
sprintf(
$this->trans('commands.site.import.local.messages.error-writing'),
- $message
+ implode("\n", $config_importer->getErrors())
)
);
} catch (\Exception $e) {
- $io->error(
+ $this->getIo()->error(
sprintf(
$this->trans('commands.site.import.local.messages.error-writing'),
$e->getMessage()