function EntityTestUpdateHooks::entityBaseFieldInfo
Implements hook_entity_base_field_info().
File
-
core/
modules/ system/ tests/ modules/ entity_test_update/ src/ Hook/ EntityTestUpdateHooks.php, line 21
Class
- EntityTestUpdateHooks
- Hook implementations for entity_test_update.
Namespace
Drupal\entity_test_update\HookCode
public function entityBaseFieldInfo(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.