ConfigManager::createSnapshot

public ConfigManager::createSnapshot(StorageInterface $source_storage, StorageInterface $snapshot_storage)

Creates a configuration snapshot following a successful import.

Parameters

\Drupal\Core\Config\StorageInterface $source_storage: The storage to synchronize configuration from.

\Drupal\Core\Config\StorageInterface $snapshot_storage: The storage to synchronize configuration to.

Overrides ConfigManagerInterface::createSnapshot

File

core/lib/Drupal/Core/Config/ConfigManager.php, line 170

Class

ConfigManager
The ConfigManager provides helper functions for the configuration system.

Namespace

Drupal\Core\Config

Code

public function createSnapshot(StorageInterface $source_storage, StorageInterface $snapshot_storage) {
  // Empty the snapshot of all configuration.
  $snapshot_storage->deleteAll();
  foreach ($snapshot_storage->getAllCollectionNames() as $collection) {
    $snapshot_collection = $snapshot_storage->createCollection($collection);
    $snapshot_collection->deleteAll();
  }
  foreach ($source_storage->listAll() as $name) {
    $snapshot_storage->write($name, $source_storage->read($name));
  }
  // Copy collections as well.
  foreach ($source_storage->getAllCollectionNames() as $collection) {
    $source_collection = $source_storage->createCollection($collection);
    $snapshot_collection = $snapshot_storage->createCollection($collection);
    foreach ($source_collection->listAll() as $name) {
      $snapshot_collection->write($name, $source_collection->read($name));
    }
  }
}
doc_Drupal
2016-10-29 08:53:59
Comments
Leave a Comment

Please login to continue.