setLabel(t('Entity synonyms')) ->setDescription(t('A list of known entity synonyms.')) ->setComputed(TRUE) ->setClass('\Drupal\synonyms\Plugin\SynonymsFieldItemList'); return $fields; } } /** * Implements hook_views_data(). */ function synonyms_views_data() { $data = []; foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type) { if ($entity_type instanceof \Drupal\Core\Entity\ContentEntityTypeInterface && $entity_type->getBaseTable() && $entity_type->getKey('id')) { $data[$entity_type->getBaseTable()]['synonyms'] = [ 'title' => t('Synonyms of @entity_type', [ '@entity_type' => $entity_type->getLowercaseLabel(), ]), 'filter' => [ 'id' => 'synonyms_entity', 'real field' => $entity_type->getKey('id'), 'entity_type' => $entity_type->id(), ], ]; } } return $data; }