You are here

public function SyncConfigCollector::addConfigForSnapshotting in Configuration Synchronizer 8.2

Adds configuration for snapshotting.

Call this method instead of ::addInstallableConfig() to add only unaltered configuration.

Parameters

\Drupal\Core\Extension\Extension[] $extensions: (Optional) An associative array of Extension objects, keyed by extension name. If provided, data loaded will be limited to these extensions.

Overrides SyncConfigCollectorInterface::addConfigForSnapshotting

File

src/Plugin/SyncConfigCollector.php, line 21

Class

SyncConfigCollector
Class for invoking configuration providers.

Namespace

Drupal\config_sync\Plugin

Code

public function addConfigForSnapshotting(array $extensions = []) {

  // Start with an empty storage.
  $this->providerStorage
    ->deleteAll();
  foreach ($this->providerStorage
    ->getAllCollectionNames() as $collection) {
    $provider_collection = $this->providerStorage
      ->createCollection($collection);
    $provider_collection
      ->deleteAll();
  }

  /* @var \Drupal\config_provider\Plugin\ConfigProviderInterface[] $providers */
  $providers = $this
    ->getConfigProviders();
  foreach ($providers as $provider) {
    if (!$provider instanceof SyncConfigProviderInterface) {
      $provider
        ->addInstallableConfig($extensions);
    }
  }
}