X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FConfig%2FImportCommand.php;h=1d0963402eebaf7c8ff4e1732eabc42d4d3d7126;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=373b3d5870ba69fe8d57b61b1c34dc3b406b2591;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/drupal/console/src/Command/Config/ImportCommand.php b/vendor/drupal/console/src/Command/Config/ImportCommand.php index 373b3d587..1d0963402 100644 --- a/vendor/drupal/console/src/Command/Config/ImportCommand.php +++ b/vendor/drupal/console/src/Command/Config/ImportCommand.php @@ -9,20 +9,16 @@ namespace Drupal\Console\Command\Config; 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 */ @@ -70,10 +66,17 @@ class ImportCommand extends Command ) ->addOption( 'remove-files', - false, + 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']); } /** @@ -81,8 +84,8 @@ class ImportCommand extends Command */ 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; @@ -94,21 +97,30 @@ class ImportCommand extends Command $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, @@ -123,23 +135,21 @@ class ImportCommand extends Command ); 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 for 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()