Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / taxonomy / src / TermViewsData.php
1 <?php
2
3 namespace Drupal\taxonomy;
4
5 use Drupal\views\EntityViewsData;
6
7 /**
8  * Provides the views data for the taxonomy entity type.
9  */
10 class TermViewsData extends EntityViewsData {
11
12   /**
13    * {@inheritdoc}
14    */
15   public function getViewsData() {
16     $data = parent::getViewsData();
17
18     $data['taxonomy_term_field_data']['table']['base']['help'] = $this->t('Taxonomy terms are attached to nodes.');
19     $data['taxonomy_term_field_data']['table']['base']['access query tag'] = 'taxonomy_term_access';
20     $data['taxonomy_term_field_data']['table']['wizard_id'] = 'taxonomy_term';
21
22     $data['taxonomy_term_field_data']['table']['join'] = [
23       // This is provided for the many_to_one argument.
24       'taxonomy_index' => [
25         'field' => 'tid',
26         'left_field' => 'tid',
27       ],
28     ];
29
30     $data['taxonomy_term_field_data']['tid']['help'] = $this->t('The tid of a taxonomy term.');
31
32     $data['taxonomy_term_field_data']['tid']['argument']['id'] = 'taxonomy';
33     $data['taxonomy_term_field_data']['tid']['argument']['name field'] = 'name';
34     $data['taxonomy_term_field_data']['tid']['argument']['zero is null'] = TRUE;
35
36     $data['taxonomy_term_field_data']['tid']['filter']['id'] = 'taxonomy_index_tid';
37     $data['taxonomy_term_field_data']['tid']['filter']['title'] = $this->t('Term');
38     $data['taxonomy_term_field_data']['tid']['filter']['help'] = $this->t('Taxonomy term chosen from autocomplete or select widget.');
39     $data['taxonomy_term_field_data']['tid']['filter']['hierarchy table'] = 'taxonomy_term_hierarchy';
40     $data['taxonomy_term_field_data']['tid']['filter']['numeric'] = TRUE;
41
42     $data['taxonomy_term_field_data']['tid_raw'] = [
43       'title' => $this->t('Term ID'),
44       'help' => $this->t('The tid of a taxonomy term.'),
45       'real field' => 'tid',
46       'filter' => [
47         'id' => 'numeric',
48         'allow empty' => TRUE,
49       ],
50     ];
51
52     $data['taxonomy_term_field_data']['tid_representative'] = [
53       'relationship' => [
54         'title' => $this->t('Representative node'),
55         'label'  => $this->t('Representative node'),
56         'help' => $this->t('Obtains a single representative node for each term, according to a chosen sort criterion.'),
57         'id' => 'groupwise_max',
58         'relationship field' => 'tid',
59         'outer field' => 'taxonomy_term_field_data.tid',
60         'argument table' => 'taxonomy_term_field_data',
61         'argument field' => 'tid',
62         'base'   => 'node_field_data',
63         'field'  => 'nid',
64         'relationship' => 'node_field_data:term_node_tid'
65       ],
66     ];
67
68     $data['taxonomy_term_field_data']['vid']['help'] = $this->t('Filter the results of "Taxonomy: Term" to a particular vocabulary.');
69     unset($data['taxonomy_term_field_data']['vid']['field']);
70     $data['taxonomy_term_field_data']['vid']['argument']['id'] = 'vocabulary_vid';
71     unset($data['taxonomy_term_field_data']['vid']['sort']);
72
73     $data['taxonomy_term_field_data']['name']['field']['id'] = 'term_name';
74     $data['taxonomy_term_field_data']['name']['argument']['many to one'] = TRUE;
75     $data['taxonomy_term_field_data']['name']['argument']['empty field name'] = $this->t('Uncategorized');
76
77     $data['taxonomy_term_field_data']['description__value']['field']['click sortable'] = FALSE;
78
79     $data['taxonomy_term_field_data']['changed']['title'] = $this->t('Updated date');
80     $data['taxonomy_term_field_data']['changed']['help'] = $this->t('The date the term was last updated.');
81
82     $data['taxonomy_term_field_data']['changed_fulldate'] = [
83       'title' => $this->t('Updated date'),
84       'help' => $this->t('Date in the form of CCYYMMDD.'),
85       'argument' => [
86         'field' => 'changed',
87         'id' => 'date_fulldate',
88       ],
89     ];
90
91     $data['taxonomy_term_field_data']['changed_year_month'] = [
92       'title' => $this->t('Updated year + month'),
93       'help' => $this->t('Date in the form of YYYYMM.'),
94       'argument' => [
95         'field' => 'changed',
96         'id' => 'date_year_month',
97       ],
98     ];
99
100     $data['taxonomy_term_field_data']['changed_year'] = [
101       'title' => $this->t('Updated year'),
102       'help' => $this->t('Date in the form of YYYY.'),
103       'argument' => [
104         'field' => 'changed',
105         'id' => 'date_year',
106       ],
107     ];
108
109     $data['taxonomy_term_field_data']['changed_month'] = [
110       'title' => $this->t('Updated month'),
111       'help' => $this->t('Date in the form of MM (01 - 12).'),
112       'argument' => [
113         'field' => 'changed',
114         'id' => 'date_month',
115       ],
116     ];
117
118     $data['taxonomy_term_field_data']['changed_day'] = [
119       'title' => $this->t('Updated day'),
120       'help' => $this->t('Date in the form of DD (01 - 31).'),
121       'argument' => [
122         'field' => 'changed',
123         'id' => 'date_day',
124       ],
125     ];
126
127     $data['taxonomy_term_field_data']['changed_week'] = [
128       'title' => $this->t('Updated week'),
129       'help' => $this->t('Date in the form of WW (01 - 53).'),
130       'argument' => [
131         'field' => 'changed',
132         'id' => 'date_week',
133       ],
134     ];
135
136     $data['taxonomy_index']['table']['group']  = $this->t('Taxonomy term');
137
138     $data['taxonomy_index']['table']['join'] = [
139       'taxonomy_term_field_data' => [
140         // links directly to taxonomy_term_field_data via tid
141         'left_field' => 'tid',
142         'field' => 'tid',
143       ],
144       'node_field_data' => [
145         // links directly to node via nid
146         'left_field' => 'nid',
147         'field' => 'nid',
148       ],
149       'taxonomy_term_hierarchy' => [
150         'left_field' => 'tid',
151         'field' => 'tid',
152       ],
153     ];
154
155     $data['taxonomy_index']['nid'] = [
156       'title' => $this->t('Content with term'),
157       'help' => $this->t('Relate all content tagged with a term.'),
158       'relationship' => [
159         'id' => 'standard',
160         'base' => 'node',
161         'base field' => 'nid',
162         'label' => $this->t('node'),
163         'skip base' => 'node',
164       ],
165     ];
166
167     // @todo This stuff needs to move to a node field since really it's all
168     //   about nodes.
169     $data['taxonomy_index']['tid'] = [
170       'group' => $this->t('Content'),
171       'title' => $this->t('Has taxonomy term ID'),
172       'help' => $this->t('Display content if it has the selected taxonomy terms.'),
173       'argument' => [
174         'id' => 'taxonomy_index_tid',
175         'name table' => 'taxonomy_term_field_data',
176         'name field' => 'name',
177         'empty field name' => $this->t('Uncategorized'),
178         'numeric' => TRUE,
179         'skip base' => 'taxonomy_term_field_data',
180       ],
181       'filter' => [
182         'title' => $this->t('Has taxonomy term'),
183         'id' => 'taxonomy_index_tid',
184         'hierarchy table' => 'taxonomy_term_hierarchy',
185         'numeric' => TRUE,
186         'skip base' => 'taxonomy_term_field_data',
187         'allow empty' => TRUE,
188       ],
189     ];
190
191     $data['taxonomy_index']['status'] = [
192       'title' => $this->t('Publish status'),
193       'help' => $this->t('Whether or not the content related to a term is published.'),
194       'filter' => [
195         'id' => 'boolean',
196         'label' => $this->t('Published status'),
197         'type' => 'yes-no',
198       ],
199     ];
200
201     $data['taxonomy_index']['sticky'] = [
202       'title' => $this->t('Sticky status'),
203       'help' => $this->t('Whether or not the content related to a term is sticky.'),
204       'filter' => [
205         'id' => 'boolean',
206         'label' => $this->t('Sticky status'),
207         'type' => 'yes-no',
208       ],
209       'sort' => [
210         'id' => 'standard',
211         'help' => $this->t('Whether or not the content related to a term is sticky. To list sticky content first, set this to descending.'),
212       ],
213     ];
214
215     $data['taxonomy_index']['created'] = [
216       'title' => $this->t('Post date'),
217       'help' => $this->t('The date the content related to a term was posted.'),
218       'sort' => [
219         'id' => 'date'
220       ],
221       'filter' => [
222         'id' => 'date',
223       ],
224     ];
225
226     $data['taxonomy_term_hierarchy']['table']['group']  = $this->t('Taxonomy term');
227     $data['taxonomy_term_hierarchy']['table']['provider']  = 'taxonomy';
228
229     $data['taxonomy_term_hierarchy']['table']['join'] = [
230       'taxonomy_term_hierarchy' => [
231         // Link to self through left.parent = right.tid (going down in depth).
232         'left_field' => 'tid',
233         'field' => 'parent',
234       ],
235       'taxonomy_term_field_data' => [
236         // Link directly to taxonomy_term_field_data via tid.
237         'left_field' => 'tid',
238         'field' => 'tid',
239       ],
240     ];
241
242     $data['taxonomy_term_hierarchy']['parent'] = [
243       'title' => $this->t('Parent term'),
244       'help' => $this->t('The parent term of the term. This can produce duplicate entries if you are using a vocabulary that allows multiple parents.'),
245       'relationship' => [
246         'base' => 'taxonomy_term_field_data',
247         'field' => 'parent',
248         'label' => $this->t('Parent'),
249         'id' => 'standard',
250       ],
251       'filter' => [
252         'help' => $this->t('Filter the results of "Taxonomy: Term" by the parent pid.'),
253         'id' => 'numeric',
254       ],
255       'argument' => [
256         'help' => $this->t('The parent term of the term.'),
257         'id' => 'taxonomy',
258       ],
259     ];
260
261     return $data;
262   }
263
264 }