-
Notifications
You must be signed in to change notification settings - Fork 3
/
asklib.views.inc
109 lines (100 loc) · 3.38 KB
/
asklib.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
use Drupal\field\FieldStorageConfigInterface;
//
function asklib_views_data_alter(array &$data) {
// var_dump($data);
// exit('AAAAALTER');
// $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
//
// $data['taxonomy_term_data']['asklib_question_tag'] = [
// 'title' => t('Related questions'),
// 'help' => t('Relate terms to questions that are tagged using the term.'),
// 'relationship' => [
// 'id' => 'standard',
// 'label' => t('Questionssss'),
// 'field' => 'tid',
// 'base' => 'asklib_question__tags',
// 'base field' => 'tags_target_id',
// 'extra' => [
// [
// 'field' => 'langcode',
// // 'value' => $langcode,
// 'left_field' => 'langcode',
// ],
// // [
// // // 'table' => 'asklib_question__tags',
// // 'field' => 'entity_id',
// // 'left_table' => 'asklib_questions',
// // 'left_field' => 'id',
// // 'type' => 'INNER',
// // ]
// ]
// ],
// 'field' => [
// 'title' => t('All questions'),
// 'help' => t('Display all questions tagged using a term'),
// 'id' => 'asklib_question_tag_tid',
// 'no group by' => TRUE,
// 'click sortable' => FALSE
// ],
// ];
//
// $data['asklib_question__tags']['question'] = [
// 'title' => t('Reverse join from tag to question'),
// 'help' => t('asdasdasd'),
// 'relationship' => [
// 'id' => 'standard',
// 'label' => t('MOAR QUESTIONS'),
// 'field' => 'entity_id',
// 'base' => 'asklib_questions',
// 'base field' => 'id',
// 'extra' => [
// [
// 'field' => 'state',
// 'value' => 2,
// 'numeric' => TRUE,
// ],
// [
// 'field' => 'published',
// 'value' => 1,
// 'numeric' => TRUE,
// ]
// ]
// ]
// ];
}
//
// function asklib_field_views_data_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) {
// exit('alter');
//
//
// $field_name = $field->getName();
// $data_key = 'field_data_' . $field_name;
// $entity_type_id = $field->entity_type;
// $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
// $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id;
// list($label) = views_entity_field_label($entity_type_id, $field_name);
// $table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping();
//
// // Views data for this field is in $data[$data_key].
// $data[$data_key][$pseudo_field_name]['relationship'] = [
// 'title' => t('@entity using @field', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
// 'help' => t('Relate each @entity with a @field set to the term.', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
// 'id' => 'entity_reverse',
// 'field_name' => $field_name,
// 'entity_type' => $entity_type_id,
// 'field table' => $table_mapping->getDedicatedDataTableName($field),
// 'field field' => $field_name . '_target_id',
// 'base' => $entity_type->getBaseTable(),
// 'base field' => $entity_type->getKey('id'),
// 'label' => $field_name,
// 'join_extra' => [
// 0 => [
// 'field' => 'deleted',
// 'value' => 0,
// 'numeric' => TRUE,
// ],
// ],
// ];
//
// }