| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Provide synonyms feature for content entities.
 
-  */
 
- /**
 
-  * Implements hook_entity_base_field_info().
 
-  */
 
- function synonyms_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
 
-   if ($entity_type instanceof \Drupal\Core\Entity\ContentEntityTypeInterface) {
 
-     $fields = [];
 
-     $fields['synonyms'] = \Drupal\Core\Field\BaseFieldDefinition::create('string')
 
-       ->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;
 
- }
 
 
  |