You are here

public function LingotekConfigTranslationService::checkConfigTargetStatuses in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  2. 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  3. 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  4. 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  5. 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  6. 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  7. 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  8. 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  9. 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  10. 3.7.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
  11. 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()

Checks the status of the translations in the Lingotek service.

Parameters

string $mapper_id: The entity which status we want to check.

Return value

boolean True if the entity is available for download.

Overrides LingotekConfigTranslationServiceInterface::checkConfigTargetStatuses

File

src/LingotekConfigTranslationService.php, line 888
Contains \Drupal\lingotek\LingotekConfigTranslationService.

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function checkConfigTargetStatuses($mapper_id) {
  $mapper = $this->mappers[$mapper_id];
  $document_id = $this
    ->getConfigDocumentId($mapper);
  $translation_statuses = $this->lingotek
    ->getDocumentTranslationStatuses($document_id);
  foreach ($translation_statuses as $lingotek_locale => $progress) {
    $drupal_language = $this->languageLocaleMapper
      ->getConfigurableLanguageForLocale($lingotek_locale);
    if ($drupal_language == NULL) {
      continue;

      // languages existing in TMS, but not configured on Drupal
    }
    $langcode = $drupal_language
      ->id();
    $current_target_status = $this
      ->getConfigTargetStatus($mapper, $langcode);
    if (in_array($current_target_status, [
      Lingotek::STATUS_UNTRACKED,
      Lingotek::STATUS_EDITED,
      Lingotek::STATUS_REQUEST,
      Lingotek::STATUS_NONE,
      Lingotek::STATUS_READY,
      Lingotek::STATUS_PENDING,
      NULL,
    ])) {
      if ($progress === Lingotek::PROGRESS_COMPLETE) {
        $this
          ->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_READY);
      }
      else {
        $this
          ->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_PENDING);
      }
    }
  }
}