function ContentTranslationHooks::entityBaseFieldInfo
Implements hook_entity_base_field_info().
Attributes
#[Hook('entity_base_field_info')]
File
- 
              core/
modules/ content_translation/ src/ Hook/ ContentTranslationHooks.php, line 263  
Class
- ContentTranslationHooks
 - Hook implementations for content_translation.
 
Namespace
Drupal\content_translation\HookCode
public function entityBaseFieldInfo(EntityTypeInterface $entity_type) : array {
  $info = [];
  /** @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/i/2907777
    if ($manager->isEnabled($entity_type_id) || array_intersect_key($definitions, $installed_storage_definitions)) {
      $info = $definitions;
    }
  }
  return $info;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.