function lingotek_entity_delete in Lingotek Translation 3.6.x
Same name and namespace in other branches
- 8 lingotek.module \lingotek_entity_delete()
- 8.2 lingotek.module \lingotek_entity_delete()
- 7.3 lingotek.module \lingotek_entity_delete()
- 7.4 lingotek.module \lingotek_entity_delete()
- 7.5 lingotek.module \lingotek_entity_delete()
- 7.6 lingotek.module \lingotek_entity_delete()
- 4.0.x lingotek.module \lingotek_entity_delete()
- 3.0.x lingotek.module \lingotek_entity_delete()
- 3.1.x lingotek.module \lingotek_entity_delete()
- 3.2.x lingotek.module \lingotek_entity_delete()
- 3.3.x lingotek.module \lingotek_entity_delete()
- 3.4.x lingotek.module \lingotek_entity_delete()
- 3.5.x lingotek.module \lingotek_entity_delete()
- 3.7.x lingotek.module \lingotek_entity_delete()
- 3.8.x lingotek.module \lingotek_entity_delete()
Implements hook_entity_delete().
File
- ./
lingotek.module, line 455 - Implements Drupal-related hooks for the Lingotek Translation module.
Code
function lingotek_entity_delete(EntityInterface $entity) {
// Only act on content entities.
if (!$entity instanceof ContentEntityInterface) {
return;
}
if (\Drupal::isConfigSyncing()) {
// We don't want to react to configuration imports.
return;
}
/** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
$translation_service = \Drupal::service('lingotek.content_translation');
// Cancel the TMS document if it's been uploaded.
if ($translation_service
->getDocumentId($entity)) {
try {
$response = $translation_service
->cancelDocument($entity);
} catch (LingotekApiException $exception) {
\Drupal::messenger()
->addError(t('Failed cancelling @entity_type %title. Please try again.', [
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
]));
}
}
}