function lingotek_entity_base_field_info in Lingotek Translation 3.0.x
Same name and namespace in other branches
- 8 lingotek.module \lingotek_entity_base_field_info()
- 8.2 lingotek.module \lingotek_entity_base_field_info()
- 4.0.x lingotek.module \lingotek_entity_base_field_info()
- 3.1.x lingotek.module \lingotek_entity_base_field_info()
- 3.2.x lingotek.module \lingotek_entity_base_field_info()
- 3.3.x lingotek.module \lingotek_entity_base_field_info()
- 3.4.x lingotek.module \lingotek_entity_base_field_info()
- 3.5.x lingotek.module \lingotek_entity_base_field_info()
- 3.6.x lingotek.module \lingotek_entity_base_field_info()
- 3.7.x lingotek.module \lingotek_entity_base_field_info()
- 3.8.x lingotek.module \lingotek_entity_base_field_info()
Implements hook_entity_base_field_info().
File
- ./
lingotek.module, line 593 - Implements Drupal-related hooks for the Lingotek Translation module.
Code
function lingotek_entity_base_field_info(EntityTypeInterface $entity_type) {
// Taken from content_translation.
/** @var \Drupal\content_translation\ContentTranslationManagerInterface $manager */
$manager = \Drupal::service('content_translation.manager');
/** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_config */
$lingotek_config = \Drupal::service('lingotek.configuration');
$entity_type_id = $entity_type
->id();
if ($manager
->isEnabled($entity_type_id) && $lingotek_config
->isEnabled($entity_type_id)) {
$definitions = \Drupal::entityTypeManager()
->getHandler($entity_type_id, 'lingotek')
->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.
if ($manager
->isEnabled($entity_type_id) || array_intersect_key($definitions, $installed_storage_definitions)) {
return $definitions;
}
}
}