function hook_uninstall
Same name in other branches
- 7.x modules/system/system.api.php \hook_uninstall()
- 9 core/lib/Drupal/Core/Extension/module.api.php \hook_uninstall()
- 10 core/lib/Drupal/Core/Extension/module.api.php \hook_uninstall()
- 11.x core/lib/Drupal/Core/Extension/module.api.php \hook_uninstall()
Remove any information that the module sets.
The information that the module should remove includes:
- state that the module has set using \Drupal::state()
- modifications to existing tables
The module should not remove its entry from the module configuration. Database tables defined by hook_schema() will be removed automatically.
The uninstall hook must be implemented in the module's .install file. It will fire when the module gets uninstalled but before the module's database tables are removed, allowing your module to query its own tables during this routine.
Parameters
bool $is_syncing: TRUE if the module is being uninstalled as part of a configuration import. In these cases, your hook implementation needs to carefully consider what changes, if any, it should make. For example, it should not make any changes to configuration objects or entities.
See also
Related topics
15 functions implement hook_uninstall()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- book_uninstall in core/
modules/ book/ book.install - Implements hook_uninstall().
- comment_uninstall in core/
modules/ comment/ comment.install - Implements hook_uninstall().
- demo_umami_content_uninstall in core/
profiles/ demo_umami/ modules/ demo_umami_content/ demo_umami_content.install - Implements hook_uninstall().
- field_layout_uninstall in core/
modules/ field_layout/ field_layout.install - Implements hook_uninstall().
- forum_uninstall in core/
modules/ forum/ forum.install - Implements hook_uninstall().
1 invocation of hook_uninstall()
- ModuleInstaller::uninstall in core/
lib/ Drupal/ Core/ Extension/ ModuleInstaller.php - Uninstalls a given list of modules.
File
-
core/
lib/ Drupal/ Core/ Extension/ module.api.php, line 312
Code
function hook_uninstall($is_syncing) {
// Delete remaining general module variables.
\Drupal::state()->delete('mymodule.foo');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.