From 5076f18365020e8558694fe86ef6a849aaaba39d Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Sat, 6 Jan 2018 23:33:09 -0800 Subject: [PATCH] [config:import] Add skip-uuid option flag. (#3638) --- src/Command/Config/ImportCommand.php | 26 ++++++++++++++++++++------ src/Override/StorageComparer.php | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 src/Override/StorageComparer.php diff --git a/src/Command/Config/ImportCommand.php b/src/Command/Config/ImportCommand.php index 90eeb26fa..4d58f4ad8 100644 --- a/src/Command/Config/ImportCommand.php +++ b/src/Command/Config/ImportCommand.php @@ -16,7 +16,7 @@ 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 { @@ -71,6 +71,12 @@ protected function configure() 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']); } @@ -81,6 +87,7 @@ 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; @@ -92,7 +99,16 @@ protected function execute(InputInterface $input, OutputInterface $output) $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')); @@ -106,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } - private function configImport(DrupalStyle $io, StorageComparer $storage_comparer) + private function configImport(DrupalStyle $io, StorageComparerInterface $storage_comparer) { $config_importer = new ConfigImporter( $storage_comparer, @@ -128,12 +144,10 @@ private function configImport(DrupalStyle $io, StorageComparer $storage_comparer $config_importer->import(); return true; } catch (ConfigImporterException $e) { - $message = $this->trans('commands.config.import.messages.import-fail') . "\n"; - $message .= implode("\n", $config_importer->getErrors()); $io->error( sprintf( $this->trans('commands.site.import.local.messages.error-writing'), - $message + implode("\n", $config_importer->getErrors()) ) ); } catch (\Exception $e) { diff --git a/src/Override/StorageComparer.php b/src/Override/StorageComparer.php new file mode 100644 index 000000000..10f8a82e6 --- /dev/null +++ b/src/Override/StorageComparer.php @@ -0,0 +1,15 @@ +