public function ExcludedModulesEventSubscriber::onConfigTransformExport in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/EventSubscriber/ExcludedModulesEventSubscriber.php \Drupal\Core\EventSubscriber\ExcludedModulesEventSubscriber::onConfigTransformExport()
- 9 core/lib/Drupal/Core/EventSubscriber/ExcludedModulesEventSubscriber.php \Drupal\Core\EventSubscriber\ExcludedModulesEventSubscriber::onConfigTransformExport()
Transform the storage which is used to export the configuration.
Make sure excluded modules are not exported by removing all the config which depends on them from the storage that is exported.
Parameters
\Drupal\Core\Config\StorageTransformEvent $event: The transformation event.
File
- core/
lib/ Drupal/ Core/ EventSubscriber/ ExcludedModulesEventSubscriber.php, line 119
Class
- ExcludedModulesEventSubscriber
- The event subscriber preventing excluded modules to be exported.
Namespace
Drupal\Core\EventSubscriberCode
public function onConfigTransformExport(StorageTransformEvent $event) {
$storage = $event
->getStorage();
if (!$storage
->exists('core.extension')) {
// If the core.extension config is not present there is nothing to do.
// This means some other process has rendered it non-functional already.
return;
}
foreach (array_merge([
StorageInterface::DEFAULT_COLLECTION,
], $storage
->getAllCollectionNames()) as $collectionName) {
$collection = $storage
->createCollection($collectionName);
foreach ($this
->getDependentConfigNames() as $configName) {
$collection
->delete($configName);
}
}
$extension = $storage
->read('core.extension');
// Remove all the excluded modules from the extensions list.
$extension['module'] = array_diff_key($extension['module'], array_flip($this
->getExcludedModules()));
$storage
->write('core.extension', $extension);
}