You are here

public function LingotekConfigTranslationService::requestConfigTranslations in Lingotek Translation 8

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

Request all translations for a given mapper in all locales.

Parameters

string $mapper_id: The entity which target we want to add.

Overrides LingotekConfigTranslationServiceInterface::requestConfigTranslations

File

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

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function requestConfigTranslations($mapper_id) {
  $mapper = $this->mappers[$mapper_id];
  $languages = [];
  if ($document_id = $this
    ->getConfigDocumentId($mapper)) {
    $target_languages = $this->languageManager
      ->getLanguages();
    $source_langcode = $mapper
      ->getLangcode();
    foreach ($target_languages as $langcode => $language) {
      $locale = $this->languageLocaleMapper
        ->getLocaleForLangcode($langcode);
      if ($langcode !== $source_langcode) {
        $source_status = $this
          ->getConfigSourceStatus($mapper);
        $current_status = $this
          ->getConfigTargetStatus($mapper, $langcode);
        if ($current_status !== Lingotek::STATUS_PENDING && $current_status !== Lingotek::STATUS_CURRENT && $current_status !== Lingotek::STATUS_EDITED && $current_status !== Lingotek::STATUS_READY) {
          if ($this->lingotek
            ->addTarget($document_id, $locale, $this->lingotekConfiguration
            ->getConfigProfile($mapper
            ->getPluginId()))) {
            $languages[] = $langcode;
            $this
              ->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_PENDING);

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