-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcalendar.views.inc
47 lines (43 loc) · 1.57 KB
/
calendar.views.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
39
40
41
42
43
44
45
46
47
<?php
/**
* @file
* Provides views data for the calendar module.
*/
use Drupal\field\FieldStorageConfigInterface;
/**
* Implements hook_views_data_alter().
*/
function calendar_views_data_alter(array &$data) {
foreach ($data as $table_name => $table_data) {
foreach ($table_data as $property_name => $properties) {
if (isset($properties['argument']) && $properties['argument']['id'] === 'date') {
$data[$table_name][$property_name . '_calendar'] = [
'title' => t('Calendar contextual filter for @name', ['@name' => $property_name,]),
'help' => t('A calendar contextual filter that handles granularity and range options.'),
'argument' => [
'field' => $property_name . '_calendar',
'id' => 'calendar_datetime',
],
];
}
}
}
}
/**
* Implements hook_field_views_data_alter().
*/
function calendar_field_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) {
if ($field_storage->getType() === 'datetime') {
foreach ($data as $table_name => $table_data) {
$data[$table_name][$field_storage->getName() . '_value_calendar'] = [
'title' => t('Calendar contextual filter for @name', ['@name' => $field_storage->getName()]),
'help' => t('A calendar contextual filter that handles granularity and range options.'),
'argument' => [
'field' => $field_storage->getName() . '_value',
'id' => 'calendar_datetime',
],
'group' => $data[$table_name][$field_storage->getName() . '_value']['group'],
];
}
}
}