function entity_schema_test_entity_base_field_info in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_base_field_info()
Implements hook_entity_base_field_info().
File
- core/
modules/ system/ tests/ modules/ entity_schema_test/ entity_schema_test.module, line 38 - Test module for the entity API providing a bundle field.
Code
function entity_schema_test_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type
->id() == 'entity_test_update') {
$definitions['custom_base_field'] = BaseFieldDefinition::create('string')
->setName('custom_base_field')
->setLabel(t('A custom base field'));
if (\Drupal::state()
->get('entity_schema_update')) {
$definitions += EntityTestMulRev::baseFieldDefinitions($entity_type);
// And add a revision log.
$definitions['revision_log'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Revision log message'))
->setDescription(t('The log entry explaining the changes in this revision.'))
->setRevisionable(TRUE);
}
return $definitions;
}
}