Mercurial > hg > isophonics-drupal-site
comparison core/modules/datetime/datetime.views.inc @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * @file | |
5 * Provides views data for the datetime module. | |
6 */ | |
7 | |
8 use Drupal\field\FieldStorageConfigInterface; | |
9 | |
10 /** | |
11 * Implements hook_field_views_data(). | |
12 */ | |
13 function datetime_field_views_data(FieldStorageConfigInterface $field_storage) { | |
14 // @todo This code only covers configurable fields, handle base table fields | |
15 // in https://www.drupal.org/node/2489476. | |
16 $data = views_field_default_views_data($field_storage); | |
17 foreach ($data as $table_name => $table_data) { | |
18 // Set the 'datetime' filter type. | |
19 $data[$table_name][$field_storage->getName() . '_value']['filter']['id'] = 'datetime'; | |
20 | |
21 // Set the 'datetime' argument type. | |
22 $data[$table_name][$field_storage->getName() . '_value']['argument']['id'] = 'datetime'; | |
23 | |
24 // Create year, month, and day arguments. | |
25 $group = $data[$table_name][$field_storage->getName() . '_value']['group']; | |
26 $arguments = [ | |
27 // Argument type => help text. | |
28 'year' => t('Date in the form of YYYY.'), | |
29 'month' => t('Date in the form of MM (01 - 12).'), | |
30 'day' => t('Date in the form of DD (01 - 31).'), | |
31 'week' => t('Date in the form of WW (01 - 53).'), | |
32 'year_month' => t('Date in the form of YYYYMM.'), | |
33 'full_date' => t('Date in the form of CCYYMMDD.'), | |
34 ]; | |
35 foreach ($arguments as $argument_type => $help_text) { | |
36 $data[$table_name][$field_storage->getName() . '_value_' . $argument_type] = [ | |
37 'title' => $field_storage->getLabel() . ' (' . $argument_type . ')', | |
38 'help' => $help_text, | |
39 'argument' => [ | |
40 'field' => $field_storage->getName() . '_value', | |
41 'id' => 'datetime_' . $argument_type, | |
42 ], | |
43 'group' => $group, | |
44 ]; | |
45 } | |
46 | |
47 // Set the 'datetime' sort handler. | |
48 $data[$table_name][$field_storage->getName() . '_value']['sort']['id'] = 'datetime'; | |
49 } | |
50 | |
51 return $data; | |
52 } |