Skip to content

Instantly share code, notes, and snippets.

@jmickela
Last active September 8, 2016 03:28
Show Gist options
  • Save jmickela/b1efaae39add69f5bd6bc12f4708f041 to your computer and use it in GitHub Desktop.
Save jmickela/b1efaae39add69f5bd6bc12f4708f041 to your computer and use it in GitHub Desktop.
Pantheon Quicksilver task to enable and disable modules on Database copy.
<?php
/**
* Enable and disable modules based on settings in $conf['qs_module_settings']
*/
// Without resorting to fixed paths, this is the easiest way to get the data from the settings file and into this script.
$module_settings = json_decode(shell_exec("drush vget qs_module_settings --exact --format=json"));
$module_list = shell_exec("drush pm-list --status=enabled --pipe 2>&1");
$enabled_modules = explode("\n", $module_list);
$module_list = shell_exec("drush pm-list --status=disabled --pipe 2>&1");
$disabled_modules = explode("\n", $module_list);
if(!$module_settings || !$enabled_modules || !$disabled_modules)
return;
foreach($module_settings->enabled as $module) {
if(in_array($module, $disabled_modules)) {
passthru("drush pm-enable -y $module");
}
}
foreach($module_settings->disabled as $module) {
if(in_array($module, $enabled_modules)) {
passthru("drush pm-disable -y $module");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment