You are here

styled_google_map.install in Styled Google Map 8.2

Same filename and directory in other branches
  1. 8 styled_google_map.install
  2. 7.2 styled_google_map.install

Installation routine.

File

styled_google_map.install
View source
<?php

/**
 * @file
 * Installation routine.
 */
use Drupal\styled_google_map\StyledGoogleMapInterface;

/**
 * Implements hook_requirements().
 */
function styled_google_map_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {

    // Whether or not an API key or client id is provided.
    $key_provided = FALSE;
    $config = \Drupal::config('styled_google_map.settings');
    switch ($config
      ->get('styled_google_map_google_auth_method')) {
      case StyledGoogleMapInterface::STYLED_GOOGLE_MAP_GOOGLE_AUTH_KEY:
        $key = $config
          ->get('styled_google_map_google_apikey');
        if ($key) {
          $key_provided = TRUE;
        }
        break;
      case StyledGoogleMapInterface::STYLED_GOOGLE_MAP_GOOGLE_AUTH_WORK:
        $client_id = $config
          ->get('styled_google_map_google_client_id');
        if ($client_id) {
          $key_provided = TRUE;
        }
        break;
    }
    if (!$key_provided) {
      $requirements['styled_google_map'] = [
        'title' => t('Styled Google Map'),
        'severity' => REQUIREMENT_WARNING,
        'value' => t('Google Maps API key or Client ID was not found. As of 2016/06/22, keyless access is no longer supported and it may impact rendering of maps. For more information visit: <a href="@link">@link</a>', [
          '@link' => 'http://googlegeodevelopers.blogspot.ca/2016/06/building-for-scale-updates-to-google.html',
        ]),
      ];
    }
  }
  return $requirements;
}

Functions