You are here

public function LingotekConfigTranslationService::cancelConfigDocumentTarget in Lingotek Translation 8.2

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

Cancels a translation for a given entity in the given locale.

Parameters

string $mapper_id: The entity being cancelled.

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

Overrides LingotekConfigTranslationServiceInterface::cancelConfigDocumentTarget

File

src/LingotekConfigTranslationService.php, line 1445

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function cancelConfigDocumentTarget($mapper_id, $locale) {
  $mapper = $this->mappers[$mapper_id];
  $profile = $this->lingotekConfiguration
    ->getConfigProfile($mapper_id);
  if ($profile
    ->id() === Lingotek::PROFILE_DISABLED || $this
    ->getConfigSourceStatus($mapper) === Lingotek::STATUS_CANCELLED) {
    return FALSE;
  }
  $source_langcode = $mapper
    ->getLangcode();
  $source_locale = $this->languageLocaleMapper
    ->getLocaleForLangcode($source_langcode);
  if ($locale == $source_locale) {

    // This is not a target, but the source language itself.
    return FALSE;
  }
  if ($document_id = $this
    ->getConfigDocumentId($mapper)) {
    $drupal_language = $this->languageLocaleMapper
      ->getConfigurableLanguageForLocale($locale);
    if ($this->lingotek
      ->cancelDocumentTarget($document_id, $locale)) {
      $this
        ->setConfigTargetStatus($mapper, $drupal_language
        ->id(), Lingotek::STATUS_CANCELLED);
      return TRUE;
    }
  }
  if ($this
    ->getConfigSourceStatus($mapper) == Lingotek::STATUS_DISABLED) {
    $this
      ->setConfigTargetStatuses($mapper, Lingotek::STATUS_DISABLED);
  }
  return FALSE;
}