Last active
September 2, 2015 10:29
-
-
Save johnennewdeeson/e5d77deaa5f45cb5de59 to your computer and use it in GitHub Desktop.
Enabling modules in an update hook.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Enable modules. | |
* Normally we'd use master module for this but sometimes you can't run anything other than updb in production. | |
*/ | |
function mymodule_update_7001(&$sandbox) { | |
$modules = array( | |
'mymodule_one', | |
'mymodule_two', | |
'mymodule_three', | |
); | |
if (!isset($sandbox['progress'])) { | |
$sandbox['progress'] = 0; | |
$sandbox['max'] = count($modules); | |
} | |
$module = $modules[$sandbox['progress']]; | |
module_enable(array($module)); | |
drupal_flush_all_caches(); | |
$sandbox['progress']++; | |
$sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment