function environment_requirements in Environment 6
Same name and namespace in other branches
- 8 environment.install \environment_requirements()
- 7 environment.install \environment_requirements()
Implementation of hook_requirements().
File
- ./
environment.install, line 27 - Handles installation of the Environment module.
Code
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;
}