SyncConfigCollector.php in Configuration Synchronizer 8.2
File
src/Plugin/SyncConfigCollector.php
View source
<?php
namespace Drupal\config_sync\Plugin;
use Drupal\config_provider\Plugin\ConfigCollector;
use Drupal\config_snapshot\ConfigSnapshotStorageTrait;
use Drupal\config_sync\ConfigSyncExtensionsTrait;
use Drupal\config_sync\ConfigSyncSnapshotterInterface;
class SyncConfigCollector extends ConfigCollector implements SyncConfigCollectorInterface {
use ConfigSnapshotStorageTrait;
use ConfigSyncExtensionsTrait;
public function addConfigForSnapshotting(array $extensions = []) {
$this->providerStorage
->deleteAll();
foreach ($this->providerStorage
->getAllCollectionNames() as $collection) {
$provider_collection = $this->providerStorage
->createCollection($collection);
$provider_collection
->deleteAll();
}
$providers = $this
->getConfigProviders();
foreach ($providers as $provider) {
if (!$provider instanceof SyncConfigProviderInterface) {
$provider
->addInstallableConfig($extensions);
}
}
}
public function alterConfigSnapshots(array $extensions = []) {
$providers = $this
->getConfigProviders();
$extension_names = $this
->getSyncExtensions();
foreach ($extension_names as $type => $names) {
foreach ($names as $name) {
$snapshot_storage = $this
->getConfigSnapshotStorage(ConfigSyncSnapshotterInterface::CONFIG_SNAPSHOT_SET, $type, $name);
foreach ($providers as $provider) {
if ($provider instanceof SyncConfigProviderInterface) {
$provider
->alterConfigSnapshot($snapshot_storage, $extensions);
}
}
}
}
}
}