function content_translation_entity_base_field_info
Same name in other branches
- 8.9.x core/modules/content_translation/content_translation.module \content_translation_entity_base_field_info()
- 10 core/modules/content_translation/content_translation.module \content_translation_entity_base_field_info()
Implements hook_entity_base_field_info().
File
-
core/
modules/ content_translation/ content_translation.module, line 268
Code
function content_translation_entity_base_field_info(EntityTypeInterface $entity_type) {
/** @var \Drupal\content_translation\ContentTranslationManagerInterface $manager */
$manager = \Drupal::service('content_translation.manager');
$entity_type_id = $entity_type->id();
if ($manager->isSupported($entity_type_id)) {
$definitions = $manager->getTranslationHandler($entity_type_id)
->getFieldDefinitions();
$installed_storage_definitions = \Drupal::service('entity.last_installed_schema.repository')->getLastInstalledFieldStorageDefinitions($entity_type_id);
// We return metadata storage fields whenever content translation is enabled
// or it was enabled before, so that we keep translation metadata around
// when translation is disabled.
// @todo Re-evaluate this approach and consider removing field storage
// definitions and the related field data if the entity type has no bundle
// enabled for translation.
// @see https://www.drupal.org/node/2907777
if ($manager->isEnabled($entity_type_id) || array_intersect_key($definitions, $installed_storage_definitions)) {
return $definitions;
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.