// necessarily installed.
foreach ($module_list as $module) { // Clean up all entity bundles (including fields) of every entity type
// provided by the module that is being uninstalled.
// @todo Clean this up in https://www.drupal.org/node/2350111.
$entity_type_manager = \Drupal::
entityTypeManager();
$entity_type_bundle_info = \Drupal::
service('entity_type.bundle.info'
);
foreach ($entity_type_manager->
getDefinitions() as $entity_type_id =>
$entity_type) { if ($entity_type->
getProvider() ==
$module) { foreach (array_keys($entity_type_bundle_info->
getBundleInfo($entity_type_id)) as $bundle) { \Drupal::
service('entity_bundle.listener'
)->
onBundleDelete($bundle,
$entity_type_id);
} } } // Allow modules to react prior to the uninstallation of a module.
$this->moduleHandler->
invokeAll('module_preuninstall',
[$module]);
// Uninstall the module.
$this->moduleHandler->
loadInclude($module, 'install'
);
$this->moduleHandler->
invoke($module, 'uninstall',
[$sync_status]);