function EntitySchemaTestHooks::entityBaseFieldInfo

Implements hook_entity_base_field_info().

File

core/modules/system/tests/modules/entity_schema_test/src/Hook/EntitySchemaTestHooks.php, line 43

Class

EntitySchemaTestHooks
Hook implementations for entity_schema_test.

Namespace

Drupal\entity_schema_test\Hook

Code

public function entityBaseFieldInfo(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.