You are here

function synonyms_entity_base_field_info in Synonyms 2.0.x

Same name and namespace in other branches
  1. 8 synonyms.module \synonyms_entity_base_field_info()

Implements hook_entity_base_field_info().

File

modules/synonyms_list_field/synonyms_list_field.module, line 16
Provides a list of entity synonyms as a field.

Code

function synonyms_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type instanceof ContentEntityTypeInterface) {
    $fields = [];
    $fields['synonyms'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Synonyms list'))
      ->setDescription(t('A list of entity synonyms.'))
      ->setComputed(TRUE)
      ->setReadOnly(TRUE)
      ->setClass('\\Drupal\\synonyms_list_field\\Field\\SynonymsFieldItemList')
      ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
      ->setDisplayConfigurable('view', TRUE);
    return $fields;
  }
}