Chris@0: t('Taxonomy terms on node'), Chris@0: 'help' => t('Relate nodes to taxonomy terms, specifying which vocabulary or vocabularies to use. This relationship will cause duplicated records if there are multiple terms.'), Chris@0: 'relationship' => [ Chris@0: 'id' => 'node_term_data', Chris@0: 'label' => t('term'), Chris@0: 'base' => 'taxonomy_term_field_data', Chris@0: ], Chris@0: 'field' => [ Chris@0: 'title' => t('All taxonomy terms'), Chris@0: 'help' => t('Display all taxonomy terms associated with a node from specified vocabularies.'), Chris@0: 'id' => 'taxonomy_index_tid', Chris@0: 'no group by' => TRUE, Chris@0: 'click sortable' => FALSE, Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['node_field_data']['term_node_tid_depth'] = [ Chris@0: 'help' => t('Display content if it has the selected taxonomy terms, or children of the selected terms. Due to additional complexity, this has fewer options than the versions without depth.'), Chris@0: 'real field' => 'nid', Chris@0: 'argument' => [ Chris@0: 'title' => t('Has taxonomy term ID (with depth)'), Chris@0: 'id' => 'taxonomy_index_tid_depth', Chris@0: 'accept depth modifier' => TRUE, Chris@0: ], Chris@0: 'filter' => [ Chris@0: 'title' => t('Has taxonomy terms (with depth)'), Chris@0: 'id' => 'taxonomy_index_tid_depth', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['node_field_data']['term_node_tid_depth_modifier'] = [ Chris@0: 'title' => t('Has taxonomy term ID depth modifier'), Chris@0: 'help' => t('Allows the "depth" for Taxonomy: Term ID (with depth) to be modified via an additional contextual filter value.'), Chris@0: 'argument' => [ Chris@0: 'id' => 'taxonomy_index_tid_depth_modifier', Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_field_views_data_alter(). Chris@0: * Chris@0: * Views integration for entity reference fields which reference taxonomy terms. Chris@0: * Adds a term relationship to the default field data. Chris@0: * Chris@0: * @see views_field_default_views_data() Chris@0: */ Chris@0: function taxonomy_field_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) { Chris@0: if ($field_storage->getType() == 'entity_reference' && $field_storage->getSetting('target_type') == 'taxonomy_term') { Chris@0: foreach ($data as $table_name => $table_data) { Chris@0: foreach ($table_data as $field_name => $field_data) { Chris@0: if (isset($field_data['filter']) && $field_name != 'delta') { Chris@0: $data[$table_name][$field_name]['filter']['id'] = 'taxonomy_index_tid'; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_views_plugins_argument_validator_alter(). Chris@0: * Chris@0: * Extend the generic entity argument validator. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\views\argument_validator\Entity Chris@0: */ Chris@0: function taxonomy_views_plugins_argument_validator_alter(array &$plugins) { Chris@0: $plugins['entity:taxonomy_term']['title'] = t('Taxonomy term ID'); Chris@0: $plugins['entity:taxonomy_term']['class'] = 'Drupal\taxonomy\Plugin\views\argument_validator\Term'; Chris@0: $plugins['entity:taxonomy_term']['provider'] = 'taxonomy'; Chris@0: }