You are here

function leaflet_requirements in Leaflet 7

Same name and namespace in other branches
  1. 8 leaflet.install \leaflet_requirements()
  2. 2.1.x leaflet.install \leaflet_requirements()
  3. 2.0.x leaflet.install \leaflet_requirements()

Implements hook_requirements().

File

./leaflet.install, line 11
Install, update, and uninstall functions for the leaflet module.

Code

function leaflet_requirements($phase) {
  $requirements = array();
  $t = get_t();

  // Verify the Leaflet library is installed correctly.
  if (in_array($phase, array(
    'runtime',
    'update',
  ))) {
    $library = libraries_detect('leaflet');
    $requirements['leaflet'] = array(
      'title' => $t('Leaflet'),
    );
    if ($library['installed']) {
      $requirements['leaflet'] += array(
        'value' => $library['version'],
        'description' => t('The Leaflet Javascript library is installed correctly. @maps available.', array(
          '@maps' => format_plural(count(leaflet_map_get_info()), 'One map', '@count maps'),
        )),
        'severity' => REQUIREMENT_OK,
      );
    }
    else {
      $requirements['leaflet'] += array(
        'value' => $library['error'],
        'description' => $library['error message'],
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}