You are here

environment.install in Environment 6

Same filename and directory in other branches
  1. 8 environment.install
  2. 7 environment.install

Handles installation of the Environment module.

File

environment.install
View source
<?php

/**
 * @file
 * Handles installation of the Environment module.
 */

/**
 * Implementation of hook_install().
 */
function environment_install() {

  // New module weights in core: put environment as the very last in the chain.
  db_query("UPDATE {system} SET weight = -100 WHERE name = 'environment'");
}

/**
 * Implementation of hook_uninstall().
 */
function environment_uninstall() {
  variable_del('environment');
  variable_del('environment_require_override');
}

/**
 * Implementation of hook_requirements().
 */
function environment_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $t = get_t();
    if (variable_get('environment_require_override', FALSE)) {
      $requirements['environment_require_override'] = array(
        'title' => $t('Environment Override'),
        'description' => $t("You should override the 'environment_override' variable in your settings.php file to indicate the server environment this site is in."),
        'value' => $t('Missing'),
        'severity' => REQUIREMENT_ERROR,
      );
    }
    $environment = (array) variable_get('environment', array());
    $env_override = (array) variable_get('environment_override', array());
    $workflows = environment_workflow_load();
    foreach ($workflows as $name => $workflow) {
      $status = environment_load($environment[$name]);
      $key = empty($name) ? 'default' : $name;
      if (isset($env_override[$name]) && $env_override[$name] != $environment['name']) {
        $requirements['environment_override_' . $key] = array(
          'title' => $t('Environment Mismatch for @workflow workflow', array(
            '@workflow' => $workflow['label'],
          )),
          'description' => $t("The environment override set in your settings.php file does not match the current system environment. Please !link or correct this setting.", array(
            '!link' => l($t('switch environments'), 'admin/settings/environment/switch/' . $env_override),
          )),
          'value' => $t('Mismatch'),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      if ($environment[$name] && empty($status)) {
        $requirements['environment_' . $key] = array(
          'title' => $t('Environment'),
          'description' => $t("The current environment '%environment' is no longer defined in your system.", array(
            '%environment' => $environment,
          )),
          'value' => $t('Invalid State'),
          'severity' => REQUIREMENT_WARNING,
        );
      }
      elseif ($environment[$name]) {
        $environment = environment_load($environment[$name]);
        $requirements['environment_' . $key] = array(
          'title' => $t('Environment'),
          'description' => isset($environment['description']) ? $environment['description'] : '',
          'value' => $environment['label'],
          'severity' => REQUIREMENT_INFO,
        );
      }
    }
  }
  return $requirements;
}

Functions

Namesort descending Description
environment_install Implementation of hook_install().
environment_requirements Implementation of hook_requirements().
environment_uninstall Implementation of hook_uninstall().