You are here

function lingotek_remove_target_locales in Lingotek Translation 7.7

1 string reference to 'lingotek_remove_target_locales'
lingotek_batch_update_entity_languages_by_profile in ./lingotek.batch.inc

File

./lingotek.batch.inc, line 903
Central location for batch create functions, before control is handed off to individual batch command files.

Code

function lingotek_remove_target_locales($entity_params, $locales, &$context) {
  $document_id = $entity_params['document_id'];
  $entity_type = $entity_params['type'];
  $entity_id = $entity_params['id'];
  if (empty($context['results'])) {
    $context['results'] = array();
  }
  if (empty($context['results']['removed'])) {

    // initialize the counter of removed targets.
    $context['results']['removed'] = 0;
  }
  $api = LingotekApi::instance();
  $document = $api
    ->getDocument($document_id);
  if ($document) {
    $doc_translation_targets = !empty($document->translationTargets) ? $document->translationTargets : array();
    $doc_current_locales = array_map(function ($target) {
      return $target->language;
    }, $doc_translation_targets);
    foreach ($locales as $l) {
      LingotekSync::deleteTargetStatus($entity_type, $entity_id, $l);
      $context['results']['removed']++;
    }
  }
}