You are here

synonyms_views_field.module in Synonyms 2.0.x

Integrates synonyms field with core Views module.

File

modules/synonyms_views_field/synonyms_views_field.module
View source
<?php

/**
 * @file
 * Integrates synonyms field with core Views module.
 */

/**
 * Implements hook_views_data().
 */
function synonyms_views_data() {
  $data = [];
  foreach (\Drupal::entityTypeManager()
    ->getDefinitions() as $entity_type) {
    $tables = [
      $entity_type
        ->getDataTable() ?? $entity_type
        ->getBaseTable(),
      $entity_type
        ->getRevisionDataTable() ?? $entity_type
        ->getRevisionTable(),
    ];
    $tables = array_filter($tables);
    foreach ($tables as $table) {
      $data[$table]['synonyms'] = [
        'title' => t('Synonyms list'),
        'help' => t('A list of entity synonyms.'),
        'field' => [
          'id' => 'field',
          'field_name' => 'synonyms',
        ],
      ];
    }
  }
  return $data;
}

Functions

Namesort descending Description
synonyms_views_data Implements hook_views_data().