- Published on
Fetching data from Config Split environments
Sometimes regardless of the active split in Configuration Split you might want to pull in data from the other inactive splits. The code below shows how you can pull in a list of splits and read the configuration from each.
$split_manager = \Drupal::service('config_split.manager');
$split_ids = $split_manager->listAll();
/** @var \Drupal\config_filter\ConfigFilterStorageFactory $conf_filter */
$conf_filter = \Drupal::service('config_filter.storage_factory');
foreach ($split_ids as $split_id) {
/** @var \Drupal\Core\Config\ImmutableConfig $split_config */
$split_config = $split_manager->getSplitConfig($split_id);
$storage = $split_manager->singleExportTarget($split_config);
/** @var \Drupal\config_filter\Config\FilteredStorageInterface $config_store */
$config_store = $conf_filter->getFilteredStorage($storage, ['config.storage']);
$config = $config_store->read('configuration item');
}