You are here

function lingotek_entity_translation_insert in Lingotek Translation 3.3.x

Same name and namespace in other branches
  1. 8 lingotek.module \lingotek_entity_translation_insert()
  2. 8.2 lingotek.module \lingotek_entity_translation_insert()
  3. 4.0.x lingotek.module \lingotek_entity_translation_insert()
  4. 3.0.x lingotek.module \lingotek_entity_translation_insert()
  5. 3.1.x lingotek.module \lingotek_entity_translation_insert()
  6. 3.2.x lingotek.module \lingotek_entity_translation_insert()
  7. 3.4.x lingotek.module \lingotek_entity_translation_insert()
  8. 3.5.x lingotek.module \lingotek_entity_translation_insert()
  9. 3.6.x lingotek.module \lingotek_entity_translation_insert()
  10. 3.7.x lingotek.module \lingotek_entity_translation_insert()
  11. 3.8.x lingotek.module \lingotek_entity_translation_insert()

Implements hook_entity_translation_insert().

File

./lingotek.module, line 617
Implements Drupal-related hooks for the Lingotek Translation module.

Code

function lingotek_entity_translation_insert(ContentEntityInterface $translation) {

  /** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_config */
  $lingotek_config = \Drupal::service('lingotek.configuration');

  /** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
  $translation_service = \Drupal::service('lingotek.content_translation');
  if ($lingotek_config
    ->isEnabled($translation
    ->getEntityTypeId(), $translation
    ->bundle())) {
    $status = $translation_service
      ->getTargetStatus($translation, $translation
      ->language()
      ->getId());

    // As untracked is a default, we save it anyway.
    if ($status === Lingotek::STATUS_REQUEST || $status === Lingotek::STATUS_UNTRACKED) {
      $translation = $translation_service
        ->setTargetStatus($translation, $translation
        ->language()
        ->getId(), Lingotek::STATUS_UNTRACKED, FALSE);
    }
  }
}