function TaxonomyViewsHooks::fieldViewsDataAlter

Implements hook_field_views_data_alter().

Views integration for entity reference fields which reference taxonomy terms. Adds a term relationship to the default field data.

See also

views_field_default_views_data()

File

core/modules/taxonomy/src/Hook/TaxonomyViewsHooks.php, line 64

Class

TaxonomyViewsHooks
Hook implementations for taxonomy.

Namespace

Drupal\taxonomy\Hook

Code

public function fieldViewsDataAlter(array &$data, FieldStorageConfigInterface $field_storage) {
    if ($field_storage->getType() == 'entity_reference' && $field_storage->getSetting('target_type') == 'taxonomy_term') {
        foreach ($data as $table_name => $table_data) {
            foreach ($table_data as $field_name => $field_data) {
                if (isset($field_data['filter']) && $field_name != 'delta') {
                    $data[$table_name][$field_name]['filter']['id'] = 'taxonomy_index_tid';
                }
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.