You are here

geolocation_here.install in Geolocation Field 8.3

Same filename and directory in other branches
  1. 8.2 modules/geolocation_here/geolocation_here.install

Handle requirements.

File

modules/geolocation_here/geolocation_here.install
View source
<?php

/**
 * @file
 * Handle requirements.
 */
use Drupal\Core\Url;

/**
 * {@inheritdoc}
 *
 * Implements hook_requirements().
 */
function geolocation_here_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {
    $requirements['geolocation_here_api_key'] = [
      'title' => t('Geolocation - HERE Maps Key'),
      'value' => t('HERE Maps ID & Code set'),
      'description' => t('A HERE Maps key is set in the <a href=":geolocation_here_settings_url">Geolocation settings</a>.', [
        ':geolocation_here_settings_url' => Url::fromRoute('geolocation_here.settings')
          ->toString(),
      ]),
      'severity' => REQUIREMENT_OK,
    ];
    if (empty(\Drupal::config('here_maps.settings')
      ->get('app_id')) || empty(\Drupal::config('here_maps.settings')
      ->get('app_code'))) {
      $requirements['geolocation_here_api_key']['value'] = t('HERE maps ID or code missing');
      $requirements['geolocation_here_api_key']['description'] = t('A HERE maps ID or code is missing in the <a href=":geolocation_here_settings_url">Geolocation settings</a>.', [
        ':geolocation_here_settings_url' => Url::fromRoute('geolocation_here.settings')
          ->toString(),
      ]);
      $requirements['geolocation_here_api_key']['severity'] = REQUIREMENT_WARNING;
    }
  }
  return $requirements;
}

/**
 * Implements hook_requirements().
 */
function geolocation_here_uninstall() {
  Drupal::configFactory()
    ->getEditable('here_maps.settings')
    ->delete();
}