-
Notifications
You must be signed in to change notification settings - Fork 0
/
THEME_NAME.theme
37 lines (33 loc) · 900 Bytes
/
THEME_NAME.theme
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
* Functions to support theming in the THEME_NAME theme.
*/
/**
* Implements hook_preprocess().
*/
function THEME_NAME_preprocess(&$variables) {
$variables['icons_path'] = THEME_NAME_get_icons_path();
$variables['current_language'] = Drupal::languageManager()
->getCurrentLanguage()
->getId();
$variables['#attached']['drupalSettings']['iconsPath'] = $variables['icons_path'];
}
/**
* Helper function to get the icons path.
*
* @return string|null
* Returns path for the icons SVG or null.
*/
function THEME_NAME_get_icons_path() {
static $icon_path;
if (!isset($icon_path)) {
global $base_secure_url;
$icon_path = $base_secure_url . '/' . drupal_get_path('theme', 'THEME_NAME') . '/dist/icons/sprite.svg';
if (!empty($icon_path)) {
// Add icons path as a global variable.
return $icon_path;
}
}
return $icon_path;
}