You are here

public function ConfigSyncSnapshotSubscriber::onConfigDistroImport in Configuration Synchronizer 8.2

Refreshes the snapshot for extensions whose updates were imported.

Parameters

\Drupal\Core\Config\ConfigImporterEvent $event: The Event to process.

File

src/EventSubscriber/ConfigSyncSnapshotSubscriber.php, line 61

Class

ConfigSyncSnapshotSubscriber
Updates the snapshot when config is imported.

Namespace

Drupal\config_sync\EventSubscriber

Code

public function onConfigDistroImport(Event $event) {
  $filters = $this->configFilterManager
    ->getDefinitions();
  $extensions = [];

  // There is a filter for each extension that had updates.
  foreach ($filters as $filter) {

    // Only process our own filters.
    if ($filter['provider'] === 'config_sync' && $filter['status'] && in_array('config_distro.storage.distro', $filter['storages'])) {
      $extensions[$filter['extension_type']][] = $filter['extension_name'];
    }
  }
  foreach ($extensions as $type => $names) {
    $this->snapshotter
      ->refreshExtensionSnapshot($type, $names, ConfigSyncSnapshotterInterface::SNAPSHOT_MODE_IMPORT);
  }

  // Clear data on previously-selected plugins.
  $this->state
    ->delete('config_sync.plugins');
  $this->configFilterManager
    ->clearCachedDefinitions();
}