You are here

function entity_test_update_entity_base_field_info in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_test_update/entity_test_update.module \entity_test_update_entity_base_field_info()

Implements hook_entity_base_field_info().

File

core/modules/system/tests/modules/entity_test_update/entity_test_update.module, line 16
Provides an entity type for testing definition and schema updates.

Code

function entity_test_update_entity_base_field_info(EntityTypeInterface $entity_type) {

  // Add a base field that will be used to test that fields added through
  // hook_entity_base_field_info() are handled correctly during a schema
  // conversion (e.g. from non-revisionable to revisionable).
  if ($entity_type
    ->id() == 'entity_test_update') {
    $fields = [];
    $fields['test_entity_base_field_info'] = BaseFieldDefinition::create('string')
      ->setLabel(new TranslatableMarkup('Field added by hook_entity_base_field_info()'))
      ->setTranslatable(TRUE)
      ->setRevisionable(TRUE);
    return $fields;
  }
}