You are here

function gathercontent_entity_base_field_info in GatherContent 8.3

Same name and namespace in other branches
  1. 8.5 gathercontent.module \gathercontent_entity_base_field_info()
  2. 8.4 gathercontent.module \gathercontent_entity_base_field_info()

Implements hook_entity_base_field_info().

Add a 'GC mapping ID' and 'GC ID fields' base field to all node types.

File

./gathercontent.module, line 39
Main module file for GatherContent module.

Code

function gathercontent_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = [];
  if ($entity_type
    ->id() === 'node') {
    $fields['gc_mapping_id'] = $storage_definition = BaseFieldDefinition::create('integer')
      ->setLabel(t('GC mapping ID'))
      ->setDescription(t('The ID of GatherContent mapping.'))
      ->setReadOnly(TRUE);
    $fields['gc_id'] = $storage_definition = BaseFieldDefinition::create('integer')
      ->setLabel(t('GC ID'))
      ->setDescription(t('The ID of GatherContent content.'))
      ->setReadOnly(TRUE);
  }
  if ($entity_type
    ->id() === 'file') {
    $fields['gc_id'] = $storage_definition = BaseFieldDefinition::create('integer')
      ->setLabel(t('GC ID'))
      ->setDescription(t('The ID of GatherContent content.'))
      ->setReadOnly(TRUE);
  }
  return $fields;
}