function apachesolr_multilingual_requirements in Apache Solr Multilingual 6.3
Same name and namespace in other branches
- 7 apachesolr_multilingual.install \apachesolr_multilingual_requirements()
Implements hook_requirements().
File
- ./
apachesolr_multilingual.install, line 37 - TODO
Code
function apachesolr_multilingual_requirements($phase) {
$requirements = array();
if ($phase != 'runtime') {
return $requirements;
}
module_load_include('admin.inc', 'apachesolr_search');
$t = get_t();
$environments = apachesolr_multilingual_load_all_environments();
$types = array_unique(array_values(apachesolr_multilingual_get_dynamic_text_field_prefixes_and_types()));
$ok = TRUE;
foreach ($environments as $environment) {
$fields = apachesolr_search_get_fields($environment);
if (!is_object($fields) || empty($fields)) {
$requirements['apachesolr_multilingual_bias_' . $environment['env_id']] = array(
'title' => $t('Apache Solr Multilingual'),
'value' => $t('Field bias settings of environment ID %id could not be verified.', array(
'%id' => $environment['env_id'],
)),
'description' => $t('Could not establish a connection to this solr index. The field bias settings could not be verified.'),
'severity' => REQUIREMENT_ERROR,
);
$ok = FALSE;
}
else {
$field_bias = apachesolr_environment_variable_get($environment['env_id'], 'field_bias', array());
foreach ($fields as $field_name => $field) {
// Only indexed fields are searchable.
if (in_array($field->type, $types) && $field->schema[0] == 'I') {
if (!array_key_exists($field_name, $field_bias)) {
$requirements['apachesolr_multilingual_bias_' . $environment['env_id']] = array(
'title' => $t('Apache Solr Multilingual'),
'value' => $t('Missing field bias settings of environment ID %id.', array(
'%id' => $environment['env_id'],
)),
'description' => $t('This solr index contains new searchable fields. These fields are ignored until you configured and saved the !field_biases.', array(
'!field_biases' => l($t('Field biases'), 'admin/settings/apachesolr/settings/' . $environment['env_id'] . '/bias'),
)),
'severity' => REQUIREMENT_WARNING,
);
$ok = FALSE;
break;
}
}
}
}
}
if ($ok) {
$requirements['apachesolr_multilingual_bias'] = array(
'title' => $t('Apache Solr Multilingual.'),
'value' => $t('Field biases'),
'description' => $t('All settings for all indexes are complete.'),
'severity' => REQUIREMENT_OK,
);
}
return $requirements;
}