Clever way to manage drupal install files

Since you can only have an implementation of hook_install() per module, it becomes tedious to manage large quantities of code. So I thought of a scheme to manage the code and keep it structured.

So I am dividing the functionality in update functions (implementations of hook_update_N()) and make a call to those functions from the implementation of hook_install().

I also write “downgrade” functions which have the format
/* Implements hook_install(). */
function module_install() {
module_update_7001(); // enables the freetouch theme
module_update_7002(); // creates the article and page content types
module_update_7003(); // creates the free software content type
}

/**
* Implements hook_uninstall().
*/
function module_uninstall() {
module_downgrade_7001(); // restores the theme to bartik
module_downgrade_7002(); // removes the page and article content
module_downgrade_7003();
}

Leave a Reply

Your email address will not be published. Required fields are marked *