You are here

function leaflet_markercluster_requirements in Leaflet Markercluster 8

Same name and namespace in other branches
  1. 7 leaflet_markercluster.module \leaflet_markercluster_requirements()

Implements hook_requirements().

File

./leaflet_markercluster.module, line 18

Code

function leaflet_markercluster_requirements($phase) {
  $requirements = array();
  if ($phase != 'runtime') {
    return $requirements;
  }
  $library = Drupal::service('library.discovery')
    ->getLibraryByName('leaflet_markercluster', 'leaflet-markercluster');
  $requirements['leaflet_markercluster'] = array(
    'title' => Drupal::translation()
      ->translate('Leaflet Markercluster library'),
  );
  if (file_exists($library['js'][0]['data'])) {
    $requirements['leaflet_markercluster']['value'] = Drupal::translation()
      ->translate('Leaflet Markercluster @version library installed at @path.', array(
      '@version' => $library['version'],
      '@path' => $library['js'][0]['data'],
    ));
    $requirements['leaflet_markercluster']['severity'] = REQUIREMENT_OK;
  }
  else {
    $requirements['leaflet_markercluster']['value'] = Drupal::translation()
      ->translate('Leaflet Markecluster @version library not found at @path. Please !download it to @directory.', array(
      '@version' => $library['version'],
      '@path' => $library['js'][0]['data'],
      '@directory' => dirname($library['js'][0]['data']),
      '!download' => Drupal::l('download', Drupal\Core\Url::fromUri($library['remote'])),
    ));
    $requirements['leaflet_markercluster']['severity'] = REQUIREMENT_ERROR;
  }
  return $requirements;
}