function hook_environment_switch in Environment 6
Same name and namespace in other branches
- 8 environment.api.php \hook_environment_switch()
- 7 environment.api.php \hook_environment_switch()
React to an environment state change.
Use this hook to specify changes to your site configuration depending on what kind of environment the site is operating in. For example, production environments should not have developer/site-builder oriented modules enabled, such as administrative UI modules.
When defining your state change actions, be careful to account for a given state always consisting of the same behaviors and configuration, regardless of how it returns to that state (which previous environment it was in.) Be careful that you do not *disable* any modules in one environment that implement a necessary instance of hook_environment_switch().
Parameters
$target_env: The name of the environment being activated.
$current_env: The name of the environment being deactivated.
$workflow: The name of the environment workflow whose current state is being switched. A "NULL" workflow is the default/generic/unspecified workflow for the site.
Return value
String summarizing changes made for drush user.
1 function implements hook_environment_switch()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- drush_environment_switch in ./
environment.drush.inc - Implementation of drush_hook_COMMAND for environment_switch.
1 invocation of hook_environment_switch()
- environment_switch in ./
environment.module - Switches between two environments.
File
- ./
environment.api.php, line 38 - Hooks provided by Environment.
Code
function hook_environment_switch($target_env, $current_env, $workflow = NULL) {
// Declare each optional development-related module
$devel_modules = array(
'devel',
'devel_generate',
'devel_node_access',
);
switch ($target_env) {
case 'production':
module_disable($devel_modules);
drupal_set_message('Disabled development modules');
return;
case 'development':
module_enable($devel_modules);
drupal_set_message('Enabled development modules');
return;
}
}