You are here

class SyncConfigCollector in Configuration Synchronizer 8.2

Class for invoking configuration providers.

Hierarchy

Expanded class hierarchy of SyncConfigCollector

1 string reference to 'SyncConfigCollector'
config_sync.services.yml in ./config_sync.services.yml
config_sync.services.yml
1 service uses SyncConfigCollector
config_sync.collector in ./config_sync.services.yml
Drupal\config_sync\Plugin\SyncConfigCollector

File

src/Plugin/SyncConfigCollector.php, line 13

Namespace

Drupal\config_sync\Plugin
View source
class SyncConfigCollector extends ConfigCollector implements SyncConfigCollectorInterface {
  use ConfigSnapshotStorageTrait;
  use ConfigSyncExtensionsTrait;

  /**
   * {@inheritdoc}
   */
  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);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function alterConfigSnapshots(array $extensions = []) {

    /* @var \Drupal\config_provider\Plugin\ConfigProviderInterface[] $providers */
    $providers = $this
      ->getConfigProviders();

    // Iterate through all extensions.
    $extension_names = $this
      ->getSyncExtensions();
    foreach ($extension_names as $type => $names) {
      foreach ($names as $name) {
        $snapshot_storage = $this
          ->getConfigSnapshotStorage(ConfigSyncSnapshotterInterface::CONFIG_SNAPSHOT_SET, $type, $name);

        // Pass the storage to each provider.
        foreach ($providers as $provider) {
          if ($provider instanceof SyncConfigProviderInterface) {
            $provider
              ->alterConfigSnapshot($snapshot_storage, $extensions);
          }
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigSnapshotStorageTrait::getConfigSnapshotStorage protected function Returns a configuration snapshot storage service.
ConfigSyncExtensionsTrait::getSyncExtensions protected function
SyncConfigCollector::addConfigForSnapshotting public function Adds configuration for snapshotting. Overrides SyncConfigCollectorInterface::addConfigForSnapshotting
SyncConfigCollector::alterConfigSnapshots public function Alters configuration snapshots. Overrides SyncConfigCollectorInterface::alterConfigSnapshots