You are here

function geolocation_yandex_requirements in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 modules/geolocation_yandex/geolocation_yandex.install \geolocation_yandex_requirements()

Implements hook_requirements().

File

modules/geolocation_yandex/geolocation_yandex.install, line 15
Handle requirements.

Code

function geolocation_yandex_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {
    $requirements['geolocation_yandex_api_key'] = [
      'title' => t('Geolocation - Yandex Maps Key'),
      'value' => t('Yandex Maps key set'),
      'description' => t('A Yandex Maps key is set in the <a href=":geolocation_yandex_settings_url">Geolocation settings</a>.', [
        ':geolocation_yandex_settings_url' => Url::fromRoute('geolocation_yandex.settings')
          ->toString(),
      ]),
      'severity' => REQUIREMENT_OK,
    ];
    if (empty(\Drupal::config('yandex_maps.settings')
      ->get('key'))) {
      $requirements['geolocation_yandex_api_key']['value'] = t('Yandex maps key missing');
      $requirements['geolocation_yandex_api_key']['description'] = t('A Yandex maps key is missing in the <a href=":geolocation_yandex_settings_url">Geolocation settings</a>.', [
        ':geolocation_yandex_settings_url' => Url::fromRoute('geolocation_yandex.settings')
          ->toString(),
      ]);
      $requirements['geolocation_yandex_api_key']['severity'] = REQUIREMENT_WARNING;
    }
  }
  return $requirements;
}