You are here

public function LingotekConfigTranslationService::setConfigTargetStatuses in Lingotek Translation 3.6.x

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

Sets the translation status of all translations of a given entity.

Parameters

\Drupal\config_translation\ConfigNamesMapper $mapper: The entity which status we want to change.

int $status: Status of the translation. Use Lingotek constants.

Return value

\Drupal\Core\Config\ConfigEntityInterface

Overrides LingotekConfigTranslationServiceInterface::setConfigTargetStatuses

10 calls to LingotekConfigTranslationService::setConfigTargetStatuses()
LingotekConfigTranslationService::addConfigTarget in src/LingotekConfigTranslationService.php
Request a translation for a given entity in the given locale.
LingotekConfigTranslationService::cancelConfigDocument in src/LingotekConfigTranslationService.php
Cancels a document from the server.
LingotekConfigTranslationService::cancelConfigDocumentTarget in src/LingotekConfigTranslationService.php
Cancels a translation for a given entity in the given locale.
LingotekConfigTranslationService::checkConfigSourceStatus in src/LingotekConfigTranslationService.php
Checks the source is uploaded correctly.
LingotekConfigTranslationService::checkConfigTargetStatus in src/LingotekConfigTranslationService.php
Checks the status of the translation in the Lingotek service.

... See full list

File

src/LingotekConfigTranslationService.php, line 1010

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function setConfigTargetStatuses(ConfigNamesMapper $mapper, $status) {
  $target_languages = $this->languageManager
    ->getLanguages();
  $entity_langcode = $mapper
    ->getLangcode();
  foreach ($target_languages as $langcode => $language) {
    if ($langcode != $entity_langcode && ($current_status = $this
      ->getConfigTargetStatus($mapper, $langcode))) {
      if ($current_status === Lingotek::STATUS_PENDING && $status === Lingotek::STATUS_REQUEST) {

        // Don't allow to pass from pending to request. We have been already
        // requested this one.
        continue;
      }
      if (in_array($current_status, [
        Lingotek::STATUS_UNTRACKED,
        Lingotek::STATUS_REQUEST,
        Lingotek::STATUS_DISABLED,
        NULL,
      ]) && $status === Lingotek::STATUS_PENDING) {
        continue;
      }
      if ($current_status == $status) {
        continue;
      }
      if ($current_status != Lingotek::STATUS_EDITED && $current_status !== Lingotek::STATUS_CURRENT) {
        $this
          ->setConfigTargetStatus($mapper, $langcode, $status);
      }
      elseif ($current_status == Lingotek::STATUS_EDITED && in_array($status, [
        Lingotek::STATUS_CURRENT,
        Lingotek::STATUS_PENDING,
      ])) {
        $this
          ->setConfigTargetStatus($mapper, $langcode, $status);
      }
      if ($status === Lingotek::STATUS_CANCELLED) {
        $this
          ->setConfigTargetStatus($mapper, $langcode, $status);
      }
      if ($status === Lingotek::STATUS_DISABLED) {
        $this
          ->setConfigTargetStatus($mapper, $langcode, $status);
      }
    }
  }
}