function geolocation_requirements in Geolocation Field 8
Implements hook_requirements().
File
- ./
geolocation.install, line 13 - Handle requirements.
Code
function geolocation_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$requirements['geolocation_api_key'] = [
'title' => t('Geolocation - Google Maps API Key'),
'value' => t('A Google Maps API key is set in the <a href=":geolocation_settings_url">Geolocation settings</a>, required to display any Google maps.', [
':geolocation_settings_url' => Url::fromRoute('geolocation.settings')
->toString(),
]),
'severity' => REQUIREMENT_OK,
];
if (empty(\Drupal::config('geolocation.settings')
->get('google_map_api_key'))) {
$requirements['geolocation_api_key']['value'] = t('A Google Maps API key required to display any Google maps is missing in the <a href=":geolocation_settings_url">Geolocation settings</a>.', [
':geolocation_settings_url' => Url::fromRoute('geolocation.settings')
->toString(),
]);
$requirements['geolocation_api_key']['severity'] = REQUIREMENT_WARNING;
}
}
return $requirements;
}