-
Notifications
You must be signed in to change notification settings - Fork 0
/
openy_prgf_session_table.module
51 lines (45 loc) · 1.48 KB
/
openy_prgf_session_table.module
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
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Implements hook_theme().
*/
function openy_prgf_session_table_theme() {
return [
'node__session__session_table_row' => [
'base hook' => 'paragraph',
],
];
}
/**
* Implements hook_preprocess_HOOK().
*/
function openy_prgf_session_table_preprocess_node(&$vars) {
$node = $vars['node'];
$node_type = $node->getType();
if ($vars['view_mode'] == 'session_table_row') {
$vars['theme_hook_suggestions'][] = 'node__session__session_table_row';
if ($node_type == 'session' && !empty($node)) {
foreach ($node->get('field_session_time')->referencedEntities() as $item) {
$times = $item->get('field_session_time_date')->getValue();
$date_start = $times[0]['value'];
$time_custom = strtotime($date_start . ' UTC');
$time_start = date("h:i A", $time_custom);
$date_end = $times[0]['end_value'];
$time_custom = strtotime($date_end . ' UTC');
$time_end = date("h:i A", $time_custom);
$date_start = date("l, F d, Y", $time_custom);
$vars['time_start'] = $time_start;
$vars['time_end'] = $time_end;
$vars['date_start'] = $date_start;
}
}
}
}
/**
* Implements hook_page_attachments().
*/
function openy_prgf_session_table_page_attachments(array &$attachments) {
$activeTheme = \Drupal::service('theme.manager')->getActiveTheme()->getName();
if ($activeTheme == 'openy_lily') {
$attachments['#attached']['library'][] = 'openy_prgf_session_table/lily_theme';
}
}