function entity_schema_test_entity_base_field_info

Same name in other branches
  1. 9 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_base_field_info()
  2. 10 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_base_field_info()
  3. 11.x 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 42

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

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