Same name and namespace in other branches
  1. 8.9.x core/modules/link/tests/modules/link_test_base_field/link_test_base_field.module \link_test_base_field_entity_base_field_info()
  2. 9 core/modules/link/tests/modules/link_test_base_field/link_test_base_field.module \link_test_base_field_entity_base_field_info()

Implements hook_entity_base_field_info().

File

core/modules/link/tests/modules/link_test_base_field/link_test_base_field.module, line 16
Contains main module functions.

Code

function link_test_base_field_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = [];
  if ($entity_type
    ->id() === 'entity_test') {
    $fields['links'] = BaseFieldDefinition::create('link')
      ->setLabel(t('Links'))
      ->setRevisionable(TRUE)
      ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
      ->setDescription(t('Add links to the entity.'))
      ->setRequired(FALSE)
      ->setSettings([
      'link_type' => LinkItemInterface::LINK_GENERIC,
      'title' => DRUPAL_REQUIRED,
    ])
      ->setDisplayOptions('form', [
      'type' => 'link_default',
      'weight' => 49,
    ]);
  }
  return $fields;
}