You are here

function environment_load in Environment 6

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

Fetches all available environments.

Parameters

$env: (optional) Name of the environment. If NULL, will return all environments. If an array, will return all environments specified in the array.

$reset: (default: FALSE) Reset the static cache and collect new data.

Return value

Return all environments or the specified environment.

9 calls to environment_load()
drush_environment_switch in ./environment.drush.inc
Implementation of drush_hook_COMMAND for environment_switch.
drush_environment_switch_validate in ./environment.drush.inc
Implementation of drush_hook_COMMAND_validate() for environment_switch.
environment_current in ./environment.module
Gets the current environment.
environment_drush_render_current in ./environment.drush.inc
Render all current environment states with full description.
environment_requirements in ./environment.install
Implementation of hook_requirements().

... See full list

File

./environment.module, line 234

Code

function environment_load($env = NULL, $reset = FALSE) {
  static $environments;
  if (!isset($environments) || $reset) {
    $environments = module_invoke_all('environment');
    $environments = array_merge($environments, variable_get('environment_definitions', array()));
    foreach ($environments as $name => $environment) {
      $environments[$name]['name'] = $name;
      if (!isset($environments[$name]['workflow'])) {
        $environments[$name]['workflow'] = 'default';
      }
    }
    drupal_alter('environment', $environments);
  }
  if (empty($env)) {
    return $environments;
  }
  elseif (is_array($env)) {
    return array_intersect_key($environments, array_flip($env));
  }
  else {
    return isset($environments[$env]) ? $environments[$env] : FALSE;
  }
}