Skip to content
Snippets Groups Projects
Commit 56805408 authored by agoradesign's avatar agoradesign Committed by Daniel Wehner
Browse files

Issue #3122980 by agoradesign: BundlePluginInstaller uninstalls field storage...

Issue #3122980 by agoradesign: BundlePluginInstaller uninstalls field storage definitions that are still in use
parent 3d3a9992
No related branches found
Tags 8.x-1.2
No related merge requests found
......@@ -82,13 +82,28 @@ class BundlePluginInstaller implements BundlePluginInstallerInterface {
$bundles = array_filter($bundle_handler->getBundleInfo(), function ($bundle_info) use ($modules) {
return in_array($bundle_info['provider'], $modules, TRUE);
});
/**
* We need to uninstall the field storage definitions in a separate loop.
*
* This way we can allow a module to re-use the same field within multiple
* bundles, allowing e.g to subclass a bundle plugin.
*
* @var \Drupal\entity\BundleFieldDefinition[] $field_storage_definitions
*/
$field_storage_definitions = [];
foreach (array_keys($bundles) as $bundle) {
$this->entityBundleListener->onBundleDelete($bundle, $entity_type->id());
foreach ($bundle_handler->getFieldDefinitions($bundle) as $definition) {
$this->fieldDefinitionListener->onFieldDefinitionDelete($definition);
$this->fieldStorageDefinitionListener->onFieldStorageDefinitionDelete($definition);
$field_storage_definitions[$definition->getName()] = $definition;
}
}
foreach ($field_storage_definitions as $definition) {
$this->fieldStorageDefinitionListener->onFieldStorageDefinitionDelete($definition);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment