You are here

synonyms.module in Synonyms 8

Provide synonyms feature for content entities.

File

synonyms.module
View source
<?php

/**
 * @file
 * Provide synonyms feature for content entities.
 */
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;

/**
 * Implements hook_entity_base_field_info().
 */
function synonyms_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type instanceof ContentEntityTypeInterface) {
    $fields = [];
    $fields['synonyms'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Entity synonyms'))
      ->setDescription(t('A list of known entity synonyms.'))
      ->setComputed(TRUE)
      ->setClass('\\Drupal\\synonyms\\Plugin\\SynonymsFieldItemList');
    return $fields;
  }
}