geolocation-8.x-3.x-dev/modules/geolocation_geocodio/geolocation_geocodio.install

modules/geolocation_geocodio/geolocation_geocodio.install
<?php

/**
 * @file
 * Sth sth dark side.
 */

use Drupal\Core\Url;

/**
 * Implements hook_requirements().
 */
function geolocation_geocodio_requirements(string $phase): array {
  $requirements = [];
  $requirements['geolocation_geocodio_composer'] = [
    'title' => t('Geolocation Geocodio - Composer dependency'),
    'value' => t('Libraries installed'),
    'description' => t('Use "composer require geocodio/geocodio-library-php" to install required library.'),
    'severity' => REQUIREMENT_OK,
  ];

  if (!class_exists('Geocodio\\Geocodio')) {
    $requirements['geolocation_geocodio_composer']['value'] = t('Libraries not installed');
    $requirements['geolocation_geocodio_composer']['severity'] = REQUIREMENT_ERROR;
  }

  if ($phase == 'runtime') {
    $requirements['geolocation_geocodio_api_key'] = [
      'title' => t('Geolocation - Geocodio API Key'),
      'value' => t('Geocodio API key set'),
      'description' => t('A Geocodio API key is set in the <a href=":geolocation_geocodio_settings_url">Geolocation settings</a>.', [':geolocation_geocodio_settings_url' => Url::fromRoute('geolocation_geocodio.settings')->toString()]),
      'severity' => REQUIREMENT_OK,
    ];

    if (empty(\Drupal::config('geolocation_geocodio.settings')->get('api_key'))) {
      $requirements['geolocation_geocodio_api_key']['value'] = t('Geocodio API key missing');
      $requirements['geolocation_geocodio_api_key']['description'] = t('A Geocodio API key is missing in the <a href=":geolocation_geocodio_settings_url">Geolocation settings</a>.', [':geolocation_geocodio_settings_url' => Url::fromRoute('geolocation_geocodio.settings')->toString()]);
      $requirements['geolocation_geocodio_api_key']['severity'] = REQUIREMENT_WARNING;
    }
  }

  return $requirements;
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc