You are here

function environment_current in Environment 7

Same name and namespace in other branches
  1. 8 environment.module \environment_current()
  2. 6 environment.module \environment_current()

Gets the current environment.

Parameters

string $workflow: (default: default) Specify an environment workflow to check. If NULL, will return the current environment state for each workflow. Default workflow will check environment states not assigned an explicit workflow, this maintains backwards compatibility.

string $default: Optional; defaults to NULL. Specify the default value if the current environment cannot be identified.

bool $load: (default: FALSE) If TRUE, loads the full environment definition.

6 calls to environment_current()
environment_admin_settings in ./environment.admin.inc
Environment admin form.
environment_allowed in ./environment.module
Check if something is allowed in the current environment.
environment_force_init in modules/environment_force/environment_force.module
Implements hook_init().
environment_readonly_user_default_permissions_alter in modules/environment_readonly/environment_readonly.module
Implements hook_user_default_permissions_alter().
environment_switch in ./environment.module
Switches between two environments.

... See full list

File

./environment.module, line 181
Module for handling changes in server environments

Code

function environment_current($workflow = 'default', $default = NULL, $load = FALSE) {
  $current = variable_get('environment', array());
  if (!is_array($current)) {
    $current = array(
      'default' => $current,
    );
  }
  if (is_null($workflow)) {
    $current = empty($current) ? $default : $current;
    return $load ? environment_load($current) : $current;
  }
  elseif (isset($current[$workflow])) {
    $current[$workflow] = empty($current[$workflow]) ? $default : $current[$workflow];
    return $load ? environment_load($current[$workflow]) : $current[$workflow];
  }
  return $default;
}