function entity_reference_test_entity_base_field_info

Same name and namespace in other branches
  1. 10 core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module \entity_reference_test_entity_base_field_info()
  2. 9 core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module \entity_reference_test_entity_base_field_info()

Implements hook_entity_base_field_info().

File

core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module, line 14

Code

function entity_reference_test_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = [];
  if ($entity_type->id() === 'entity_test') {
    $fields['user_role'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('User role'))
      ->setDescription(t('The role of the associated user.'))
      ->setSetting('target_type', 'user_role')
      ->setSetting('handler', 'default');
  }
  return $fields;
}

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