W3cubDocs

/Drupal 8

public function 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));
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!ConfigManager.php/function/ConfigManager::createSnapshot/8.1.x