leaflet_markercluster.module in Leaflet Markercluster 8
File
leaflet_markercluster.module
View source
<?php
function leaflet_markercluster_preprocess_leaflet_map(&$vars) {
$vars['#attached']['library'][] = 'leaflet_markercluster/leaflet-markercluster';
$vars['#attached']['library'][] = 'leaflet_markercluster/leaflet-markercluster-drupal';
}
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;
}