是否有一个我可以在模块中实现的 Hook ,以便在卸载模块时可以运行一些清理代码。我使用 variable_set()
创建了许多变量,我想在卸载模块时删除这些变量。
最佳答案
是的。
在哪里编写像这样的安装 Hook :
/**
* Implements hook_install().
*/
function annotate_install(){
// Use schema API to create database table
drupal_install_schema('annotate');
}
卸载看起来像这样:
/**
* Implements hook_uninstall().
*/
function annotate_uninstall(){
// Use scheme API to delete database table
drupal_uninstall_schema('annotate');
// Delete our module's variable from variables table
variable_del('annotate_node_types');
}
关于drupal - 模块卸载清理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3570202/