3 namespace Drupal\taxonomy;
5 use Drupal\views\EntityViewsData;
8 * Provides the views data for the taxonomy entity type.
10 class TermViewsData extends EntityViewsData {
15 public function getViewsData() {
16 $data = parent::getViewsData();
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';
22 $data['taxonomy_term_field_data']['table']['join'] = [
23 // This is provided for the many_to_one argument.
26 'left_field' => 'tid',
30 $data['taxonomy_term_field_data']['tid']['help'] = $this->t('The tid of a taxonomy term.');
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;
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;
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',
48 'allow empty' => TRUE,
52 $data['taxonomy_term_field_data']['tid_representative'] = [
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',
64 'relationship' => 'node_field_data:term_node_tid'
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']);
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');
77 $data['taxonomy_term_field_data']['description__value']['field']['click sortable'] = FALSE;
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.');
82 $data['taxonomy_term_field_data']['changed_fulldate'] = [
83 'title' => $this->t('Updated date'),
84 'help' => $this->t('Date in the form of CCYYMMDD.'),
87 'id' => 'date_fulldate',
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.'),
96 'id' => 'date_year_month',
100 $data['taxonomy_term_field_data']['changed_year'] = [
101 'title' => $this->t('Updated year'),
102 'help' => $this->t('Date in the form of YYYY.'),
104 'field' => 'changed',
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).'),
113 'field' => 'changed',
114 'id' => 'date_month',
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).'),
122 'field' => 'changed',
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).'),
131 'field' => 'changed',
136 $data['taxonomy_index']['table']['group'] = $this->t('Taxonomy term');
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',
144 'node_field_data' => [
145 // links directly to node via nid
146 'left_field' => 'nid',
149 'taxonomy_term_hierarchy' => [
150 'left_field' => 'tid',
155 $data['taxonomy_index']['nid'] = [
156 'title' => $this->t('Content with term'),
157 'help' => $this->t('Relate all content tagged with a term.'),
161 'base field' => 'nid',
162 'label' => $this->t('node'),
163 'skip base' => 'node',
167 // @todo This stuff needs to move to a node field since really it's all
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.'),
174 'id' => 'taxonomy_index_tid',
175 'name table' => 'taxonomy_term_field_data',
176 'name field' => 'name',
177 'empty field name' => $this->t('Uncategorized'),
179 'skip base' => 'taxonomy_term_field_data',
182 'title' => $this->t('Has taxonomy term'),
183 'id' => 'taxonomy_index_tid',
184 'hierarchy table' => 'taxonomy_term_hierarchy',
186 'skip base' => 'taxonomy_term_field_data',
187 'allow empty' => TRUE,
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.'),
196 'label' => $this->t('Published status'),
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.'),
206 'label' => $this->t('Sticky status'),
211 'help' => $this->t('Whether or not the content related to a term is sticky. To list sticky content first, set this to descending.'),
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.'),
226 $data['taxonomy_term_hierarchy']['table']['group'] = $this->t('Taxonomy term');
227 $data['taxonomy_term_hierarchy']['table']['provider'] = 'taxonomy';
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',
235 'taxonomy_term_field_data' => [
236 // Link directly to taxonomy_term_field_data via tid.
237 'left_field' => 'tid',
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.'),
246 'base' => 'taxonomy_term_field_data',
248 'label' => $this->t('Parent'),
252 'help' => $this->t('Filter the results of "Taxonomy: Term" by the parent pid.'),
256 'help' => $this->t('The parent term of the term.'),