You are here

protected function ConfigSyncInitializer::seedMergeStorage in Configuration Synchronizer 8

Seeds the merge storage with the current active configuration.

See also

ConfigController::downloadExport()

1 call to ConfigSyncInitializer::seedMergeStorage()
ConfigSyncInitializer::initialize in src/ConfigSyncInitializer.php
Initializes the merge storage with available configuration updates.

File

src/ConfigSyncInitializer.php, line 154

Class

ConfigSyncInitializer
Returns responses for config module routes.

Namespace

Drupal\config_sync

Code

protected function seedMergeStorage() {

  // Clear out any existing data.
  $this->mergedStorage
    ->deleteAll();

  // First, export all configuration from the active storage.
  // Get raw configuration data without overrides.
  foreach ($this->configManager
    ->getConfigFactory()
    ->listAll() as $name) {
    $this->mergedStorage
      ->write($name, $this->configManager
      ->getConfigFactory()
      ->get($name)
      ->getRawData());
  }

  // Get all override data from the remaining collections.
  foreach ($this->activeStorage
    ->getAllCollectionNames() as $collection) {
    $collection_storage = $this->activeStorage
      ->createCollection($collection);
    $merged_collection_storage = $this->mergedStorage
      ->createCollection($collection);
    $merged_collection_storage
      ->deleteAll();
    foreach ($collection_storage
      ->listAll() as $name) {
      $merged_collection_storage
        ->write($name, $collection_storage
        ->read($name));
    }
  }
}