function hook_entity_base_field_info in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_base_field_info()
Provides custom base field definitions for a content entity type.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.
Return value
\Drupal\Core\Field\FieldDefinitionInterface[] An array of field definitions, keyed by field name.
See also
hook_entity_base_field_info_alter()
hook_entity_bundle_field_info()
hook_entity_bundle_field_info_alter()
\Drupal\Core\Field\FieldDefinitionInterface
\Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions()
Related topics
8 functions implement hook_entity_base_field_info()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- contact_storage_test_entity_base_field_info in core/
modules/ contact/ tests/ modules/ contact_storage_test/ contact_storage_test.module - Implements hook_entity_base_field_info().
- content_translation_entity_base_field_info in core/
modules/ content_translation/ content_translation.module - Implements hook_entity_base_field_info().
- entity_reference_test_entity_base_field_info in core/
modules/ system/ tests/ modules/ entity_reference_test/ entity_reference_test.module - Implements hook_entity_base_field_info().
- entity_schema_test_entity_base_field_info in core/
modules/ system/ tests/ modules/ entity_schema_test/ entity_schema_test.module - Implements hook_entity_base_field_info().
- entity_test_entity_base_field_info in core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module - Implements hook_entity_base_field_info().
1 invocation of hook_entity_base_field_info()
- EntityFieldManager::buildBaseFieldDefinitions in core/
lib/ Drupal/ Core/ Entity/ EntityFieldManager.php - Builds base field definitions for an entity type.
File
- core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1666 - Hooks and documentation related to entities.
Code
function hook_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
if ($entity_type
->id() == 'node') {
$fields = array();
$fields['mymodule_text'] = BaseFieldDefinition::create('string')
->setLabel(t('The text'))
->setDescription(t('A text property added by mymodule.'))
->setComputed(TRUE)
->setClass('\\Drupal\\mymodule\\EntityComputedText');
return $fields;
}
}