hook_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type)
Provides custom base field definitions for a content entity type.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.
\Drupal\Core\Field\FieldDefinitionInterface[] An array of field definitions, keyed by field name.
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()
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; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api.php/function/hook_entity_base_field_info/8.1.x