You are here

function environment_requirements in Environment 8

Same name and namespace in other branches
  1. 6 environment.install \environment_requirements()
  2. 7 environment.install \environment_requirements()

Implements hook_requirements().

File

./environment.install, line 30
Handles installation of the Environment module.

Code

function environment_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $t = 't';
    $env_req_override = \Drupal::config('environment.settings')
      ->get('environment_require_override');
    $env_current = environment_current(TRUE);
    if ($env_req_override) {
      $env_override = \Drupal::config('environment.settings')
        ->get('environment_override');
      if (empty($env_override)) {
        $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,
        );
      }
      else {
        $requirements['environment_require_override'] = array(
          'title' => $t('Environment Override'),
          'description' => $t("The 'environment_override' variable is properly set in settings.php or elsewhere."),
          'value' => $t('Exists'),
          'severity' => REQUIREMENT_OK,
        );
      }
    }
    if (empty($env_current)) {
      $requirements['environment'] = array(
        'title' => $t('Environment'),
        'description' => $t('The environment is not set in your system.'),
        'value' => $t('Invalid State'),
        'severity' => REQUIREMENT_WARNING,
      );
    }
    else {
      $requirements['environment_' . $key] = array(
        'title' => $t('Environment'),
        'description' => $env_current
          ->get('id'),
        'value' => $env_current
          ->get('label'),
        'severity' => REQUIREMENT_INFO,
      );
    }
  }
  return $requirements;
}