hook_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions)
Provides field definitions for a specific bundle within an entity type.
Bundle fields either have to override an existing base field, or need to provide a field storage definition via hook_entity_field_storage_info() unless they are computed.
@todo WARNING: This hook will be changed in https://www.drupal.org/node/2346347.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.
string $bundle: The bundle.
\Drupal\Core\Field\FieldDefinitionInterface[] $base_field_definitions: The list of base field definitions for the entity type.
\Drupal\Core\Field\FieldDefinitionInterface[] An array of bundle field definitions, keyed by field name.
hook_entity_base_field_info_alter()
hook_entity_field_storage_info()
hook_entity_field_storage_info_alter()
hook_entity_bundle_field_info_alter()
\Drupal\Core\Field\FieldDefinitionInterface
\Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions()
function hook_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) { // Add a property only to nodes of the 'article' bundle. if ($entity_type->id() == 'node' && $bundle == 'article') { $fields = array(); $fields['mymodule_text_more'] = BaseFieldDefinition::create('string') ->setLabel(t('More text')) ->setComputed(TRUE) ->setClass('\Drupal\mymodule\EntityComputedMoreText'); 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_bundle_field_info/8.1.x