-
-
Save cam8001/1bd38cc0317b4b5ed5e0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* @file | |
* Custom Drush integration. | |
*/ | |
/** | |
* Implements hook_drush_command(). | |
* | |
* @return | |
* An associative array describing your command(s). | |
*/ | |
function golocal_drush_command() { | |
return array( | |
'golocal' => array( | |
'description' => dt('Puts your site in local development mode.'), | |
), | |
); | |
} | |
/** | |
* Put the site in local development mode. | |
*/ | |
function drush_golocal() { | |
$email = '[email protected]'; | |
// Enable dev friendly modules. | |
$modules = array('devel', 'reroute_email', 'dblog', 'update', 'diff', 'field_ui'); | |
foreach ($modules as $module) { | |
if (!module_exists($module)) { | |
if (module_enable(array($module), TRUE)) { | |
drush_log("Enabled module $module", 'ok'); | |
} | |
} | |
} | |
// Disable any production modules that you don't want to run locally, like | |
// CDN. | |
$disable = array(); | |
module_disable($disable); | |
drush_log(dt('Modules disabled: @modules', array('@modules' => implode(', ', $disable))), 'ok'); | |
// Make sure the rerouting of email is turned on so we don't send emails to | |
// actual users from our local installations. | |
if(module_exists('reroute_email')) { | |
variable_set('reroute_email_enable', 1); | |
variable_set('reroute_email_address', $email); | |
drush_log("Email is being rerouted to {$email}", 'ok'); | |
} else { | |
drush_log('Emails will be sent to users!', 'warning'); | |
} | |
// Allow everyone to see devel messages like dpm(). | |
if(module_exists('devel')) { | |
user_role_grant_permissions(1, array('access devel information')); | |
user_role_grant_permissions(2, array('access devel information')); | |
} | |
// Set some dev-friendly settings | |
variable_set('cache', "0"); | |
variable_set('block_cache', "0"); | |
variable_set('error_level', "2"); | |
variable_set('preprocess_js', "0"); | |
variable_set('preprocess_css', "0"); | |
variable_set('page_compression', "0"); | |
drush_log('Page cache, page compression, JS optimization, and CSS optimization disabled.', 'ok'); | |
// Rebuild local registry. | |
registry_rebuild(); | |
drush_log('Registry rebuilt.', 'ok'); | |
drupal_flush_all_caches(); | |
drush_log('All caches cleared.', 'ok'); | |
// Running cron. | |
drupal_cron_run(); | |
drush_log('Cron ran.', 'ok'); | |
drush_log('Site ready for development!', 'ok'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment