protected function ConfigSyncSnapshotter::snapshotNewItems in Configuration Synchronizer 8.2
Snapshot items that are installed but haven't yet been snapshotted.
Certain configuration items are installed subsequent to the installation of the modules that provide them. This is true of optional configuration when the conditions for installation are met subsequent to the initial installation of the providing module.
To cover these cases, we detect and snapshot such items.
1 call to ConfigSyncSnapshotter::snapshotNewItems()
- ConfigSyncSnapshotter::refreshExtensionSnapshot in src/
ConfigSyncSnapshotter.php - Takes a snapshot of configuration from specified modules or themes.
File
- src/
ConfigSyncSnapshotter.php, line 140
Class
- ConfigSyncSnapshotter
- The ConfigSyncSnapshotter provides helper functions for taking snapshots of extension-provided configuration.
Namespace
Drupal\config_syncCode
protected function snapshotNewItems() {
$extension_changelists = $this->configSyncLister
->getExtensionChangelists();
// Populate the provider storage with all available configuration.
$this->configCollector
->addInstallableConfig();
foreach ($extension_changelists as $type => $extensions) {
foreach ($extensions as $name => $collection_changelists) {
$snapshot_storage = $this
->getConfigSnapshotStorage(ConfigSyncSnapshotterInterface::CONFIG_SNAPSHOT_SET, $type, $name);
foreach ($collection_changelists as $collection => $operation_types) {
// Switch collection storages if necessary.
if ($collection !== $snapshot_storage
->getCollectionName()) {
$snapshot_storage = $snapshot_storage
->createCollection($collection);
}
// Create operations indicate the configuration is provided but
// hasn't been snapshotted.
if (isset($operation_types['create'])) {
foreach (array_keys($operation_types['create']) as $config_id) {
// If the item exists but there's no snapshot, create one.
if ($this
->getActiveStorages($collection)
->exists($config_id)) {
$snapshot_storage
->write($config_id, $this->providerStorage
->read($config_id));
}
}
}
}
}
}
}