function lingotek_entity_presave in Lingotek Translation 3.7.x
Same name and namespace in other branches
- 8 lingotek.module \lingotek_entity_presave()
- 8.2 lingotek.module \lingotek_entity_presave()
- 7.7 lingotek.module \lingotek_entity_presave()
- 7.4 lingotek.module \lingotek_entity_presave()
- 7.5 lingotek.module \lingotek_entity_presave()
- 7.6 lingotek.module \lingotek_entity_presave()
- 4.0.x lingotek.module \lingotek_entity_presave()
- 3.0.x lingotek.module \lingotek_entity_presave()
- 3.1.x lingotek.module \lingotek_entity_presave()
- 3.2.x lingotek.module \lingotek_entity_presave()
- 3.3.x lingotek.module \lingotek_entity_presave()
- 3.4.x lingotek.module \lingotek_entity_presave()
- 3.5.x lingotek.module \lingotek_entity_presave()
- 3.6.x lingotek.module \lingotek_entity_presave()
- 3.8.x lingotek.module \lingotek_entity_presave()
Implements hook_entity_presave().
File
- ./
lingotek.module, line 60 - Implements Drupal-related hooks for the Lingotek Translation module.
Code
function lingotek_entity_presave(EntityInterface $entity) {
$configuration_service = \Drupal::service('lingotek.configuration');
if ($entity instanceof ContentEntityInterface && $configuration_service
->isEnabled($entity
->getEntityTypeId(), $entity
->bundle())) {
if ($entity
->language() === $entity
->getUntranslated()
->language()) {
if ($entity->lingotek_metadata->entity === NULL) {
$metadata = LingotekContentMetadata::create();
$metadata
->save();
$entity->lingotek_metadata = $metadata;
}
$translation_service = \Drupal::service('lingotek.content_translation');
$translation_service
->updateEntityHash($entity);
}
}
}