function link_test_base_field_entity_base_field_info
Same name in other branches
- 9 core/modules/link/tests/modules/link_test_base_field/link_test_base_field.module \link_test_base_field_entity_base_field_info()
- 8.9.x core/modules/link/tests/modules/link_test_base_field/link_test_base_field.module \link_test_base_field_entity_base_field_info()
- 11.x core/modules/link/tests/modules/link_test_base_field/link_test_base_field.module \link_test_base_field_entity_base_field_info()
Implements hook_entity_base_field_info().
File
-
core/
modules/ link/ tests/ modules/ link_test_base_field/ link_test_base_field.module, line 16
Code
function link_test_base_field_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
if ($entity_type->id() === 'entity_test') {
$fields['links'] = BaseFieldDefinition::create('link')->setLabel(t('Links'))
->setRevisionable(TRUE)
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setDescription(t('Add links to the entity.'))
->setRequired(FALSE)
->setSettings([
'link_type' => LinkItemInterface::LINK_GENERIC,
'title' => DRUPAL_REQUIRED,
])
->setDisplayOptions('form', [
'type' => 'link_default',
'weight' => 49,
]);
}
return $fields;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.