You are here

public function LingotekConfigTranslationService::downloadConfig in Lingotek Translation 8

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

Downloads a document to the Lingotek service.

Parameters

string $mapper_id: The entity being uploaded.

string $locale: Lingotek translation language which we want to modify.

Return value

boolean TRUE if the document was downloaded successfully, FALSE if not.

Overrides LingotekConfigTranslationServiceInterface::downloadConfig

File

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

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function downloadConfig($mapper_id, $locale) {
  $mapper = $this->mappers[$mapper_id];
  if ($document_id = $this
    ->getConfigDocumentId($mapper)) {
    try {
      $data = $this->lingotek
        ->downloadDocument($document_id, $locale);
    } catch (LingotekApiException $exception) {

      // TODO: log issue
      return FALSE;
    }
    if ($data) {
      $langcode = $this->languageLocaleMapper
        ->getConfigurableLanguageForLocale($locale)
        ->getId();
      $this
        ->saveConfigTargetData($mapper, $langcode, $data);

      // If the status was "Importing", and the target was added
      // successfully, we can ensure that the content is current now.
      $source_status = $this
        ->getConfigSourceStatus($mapper);
      if ($source_status == Lingotek::STATUS_IMPORTING || $source_status == Lingotek::STATUS_EDITED) {
        $this
          ->setConfigSourceStatus($mapper, Lingotek::STATUS_CURRENT);
      }
      $this
        ->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_CURRENT);
      return TRUE;
    }
  }
  return FALSE;
}