protected function buildBundleFieldDefinitions($entity_type_id,
$bundle, array
$base_field_definitions) { $entity_type =
$this->entityTypeManager->
getDefinition($entity_type_id);
// Use a bundle specific class if one is defined.
$class =
$this->entityTypeManager->
getStorage($entity_type_id)->
getEntityClass($bundle);
// Allow the entity class to provide bundle fields and bundle-specific
// overrides of base fields.
$bundle_field_definitions =
$class::
bundleFieldDefinitions($entity_type,
$bundle,
$base_field_definitions);
// Load base field overrides from configuration. These take precedence over
// base field overrides returned above.
$base_field_override_ids =
array_map(function D
$field_name) use ($entity_type_id,
$bundle) { return $entity_type_id . '.' .
$bundle . '.' .
$field_name;
},
array_keys($base_field_definitions));
$base_field_overrides =
$this->entityTypeManager->
getStorage('base_field_override'
)->
loadMultiple($base_field_override_ids);
foreach ($base_field_overrides as $base_field_override) { /** @var \Drupal\Core\Field\Entity\BaseFieldOverride $base_field_override */
$field_name =
$base_field_override->
getName();
$bundle_field_definitions[$field_name] =
$base_field_override;
}