-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules.theme.inc
38 lines (35 loc) · 1.12 KB
/
rules.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
38
<?php
/**
* @file
* Rules theme preprocessor function to prepare variables for use in templates.
*/
/**
* Prepares variables for rules debug log element templates.
*
* Default template: rules-debug-log-element.html.twig.
*
* @param array $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #id, #attributes, #children.
*/
function template_preprocess_rules_debug_log_element(array &$variables) {
$element = $variables['element'];
// Ensure #attributes is set.
$element += [
'#attributes' => [],
];
// Here we just prepare the variables we send to the template.
$formatted_diff = round(($element['#timestamp'] - $element['#starttime']) * 1000, 3) . ' ms';
$variables['time'] = $formatted_diff;
$variables['level'] = $element['#level'];
$variables['text'] = $element['#text'];
if (isset($element['#link'])) {
$variables['link'] = [
'#type' => 'link',
'#title' => $element['#link']['title'],
'#url' => $element['#link']['url'],
];
}
$variables['attributes'] = $element['#attributes'];
}