function wbm2cm_module_preuninstall in Workbench Moderation to Content Moderation 8.2
Implements hook_module_preuninstall().
File
- ./
wbm2cm.module, line 102
Code
function wbm2cm_module_preuninstall($module) {
if (\Drupal::isConfigSyncing()) {
return;
}
elseif ($module == 'workbench_moderation') {
$entity_type_manager = \Drupal::entityTypeManager();
foreach ($entity_type_manager
->getDefinitions() as $id => $entity_type) {
if ($entity_type
->getBundleOf()) {
$storage = $entity_type_manager
->getStorage($id);
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $bundle */
foreach ($storage
->loadMultiple() as $bundle) {
$bundle
->unsetThirdPartySetting('workbench_moderation', 'enabled')
->unsetThirdPartySetting('workbench_moderation', 'allowed_moderation_states')
->unsetThirdPartySetting('workbench_moderation', 'default_moderation_state');
$storage
->save($bundle);
}
}
}
}
}