-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathowntracks.theme.inc
37 lines (32 loc) · 1.11 KB
/
owntracks.theme.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* @file
* Preprocessors and theme functions of OwnTracks module.
*/
use Drupal\Core\Template\Attribute;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Xss;
/**
* Prepares variables for owntracks_map templates.
*
* Default template: owntracks-map.html.twig.
*
* @param array $variables
* An associative array containing:
* - track: An array of Lat/Lang coordinates.
*/
function template_preprocess_owntracks_map(array &$variables) {
$id = Html::getUniqueId('owntracks-map');
$variables['attributes'] = new Attribute([
'id' => $id,
'class' => ['owntracks-map'],
]);
$variables['#attached']['library'][] = 'owntracks/owntracks';
$variables['#attached']['drupalSettings']['owntracks']['track'][$id] = $variables['track'];
$config = \Drupal::config('owntracks.map.settings');
$variables['#attached']['drupalSettings']['owntracks']['map'] = [
'tileLayerUrl' => Html::escape($config->get('tileLayerUrl')),
'tileLayerAttribution' => Xss::filterAdmin($config->get('tileLayerAttribution')),
'polylineColor' => Html::escape($config->get('polylineColor')),
];
}