Same name and namespace in other branches
- 8.9.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php \Drupal\entity_test\Entity\EntityTest::baseFieldDefinitions()
- 9 core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php \Drupal\entity_test\Entity\EntityTest::baseFieldDefinitions()
16 calls to EntityTest::baseFieldDefinitions()
- CommentTestBaseField::baseFieldDefinitions in core/
modules/ comment/ tests/ modules/ comment_base_field_test/ src/ Entity/ CommentTestBaseField.php - Provides base field definitions for an entity type.
- EntitySerializedField::baseFieldDefinitions in core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntitySerializedField.php - Provides base field definitions for an entity type.
- EntityTestBaseFieldDisplay::baseFieldDefinitions in core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestBaseFieldDisplay.php - Provides base field definitions for an entity type.
- EntityTestCompositeConstraint::baseFieldDefinitions in core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestCompositeConstraint.php - Provides base field definitions for an entity type.
- EntityTestComputedBundleField::baseFieldDefinitions in core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestComputedBundleField.php - Provides base field definitions for an entity type.
16 methods override EntityTest::baseFieldDefinitions()
- CommentTestBaseField::baseFieldDefinitions in core/
modules/ comment/ tests/ modules/ comment_base_field_test/ src/ Entity/ CommentTestBaseField.php - Provides base field definitions for an entity type.
- EntitySerializedField::baseFieldDefinitions in core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntitySerializedField.php - Provides base field definitions for an entity type.
- EntityTestBaseFieldDisplay::baseFieldDefinitions in core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestBaseFieldDisplay.php - Provides base field definitions for an entity type.
- EntityTestCompositeConstraint::baseFieldDefinitions in core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestCompositeConstraint.php - Provides base field definitions for an entity type.
- EntityTestComputedBundleField::baseFieldDefinitions in core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestComputedBundleField.php - Provides base field definitions for an entity type.
File
- core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTest.php, line 69
Class
- EntityTest
- Defines the test entity class.
Namespace
Drupal\entity_test\EntityCode
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the test entity.'))
->setTranslatable(TRUE)
->setSetting('max_length', 64)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
]);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Authored on'))
->setDescription(t('Time the entity was created'))
->setTranslatable(TRUE);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('User ID'))
->setDescription(t('The ID of the associated user.'))
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setDefaultValue([
0 => [
'target_id' => 1,
],
])
->setTranslatable(TRUE)
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => -1,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'placeholder' => '',
],
]);
return $fields + \Drupal::state()
->get($entity_type
->id() . '.additional_base_field_definitions', []);
}