function 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 17

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;
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.