function cms_content_sync_uninstall in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x cms_content_sync.install \cms_content_sync_uninstall()
- 2.0.x cms_content_sync.install \cms_content_sync_uninstall()
Implements hook_uninstall().
File
- ./
cms_content_sync.install, line 118 - Install file for cms_content_sync.
Code
function cms_content_sync_uninstall() {
// Delete CMS Content Sync User.
$user = User::load(CMS_CONTENT_SYNC_USER_ID);
if (isset($user)) {
$user
->delete();
}
// Delete entry from key value table.
Drupal::service('keyvalue.database')
->get('cms_content_sync_user')
->delete('uid');
/**
* @var \Drupal\Core\Config\CachedStorage $config_storage
*/
$config_storage = Drupal::service('config.storage');
// Drupal doesn't delete config automatically, so we need to ensure that
// everything is deleted properly. Otherwise you may get a fatal error after
// uninstalling the module about missing REST interfaces or you may not be
// able to install the module again afterwards.
$configsNames = [
'key.key.cms_content_sync',
'encrypt.profile.cms_content_sync',
'rest.resource.cms_content_sync_entity_resource',
'rest.resource.cms_content_sync_import_entity',
'system.action.node_cms_content_sync_export_action',
'user.role.cms_content_sync',
'system.action.user_remove_role_action.cms_content_sync',
'system.action.user_add_role_action.cms_content_sync',
];
foreach ($configsNames as $name) {
$config_storage
->delete($name);
}
}