You are here

public function LingotekContentTranslationService::markTranslationsAsDirty in Lingotek Translation 4.0.x

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

Marks the translation status as dirty if they exist.

Parameters

\Drupal\Core\Entity\ContentEntityInterface &$entity: The entity which status we want to change.

Return value

\Drupal\Core\Entity\ContentEntityInterface

Overrides LingotekContentTranslationServiceInterface::markTranslationsAsDirty

File

src/LingotekContentTranslationService.php, line 517

Class

LingotekContentTranslationService
Service for managing Lingotek content translations.

Namespace

Drupal\lingotek

Code

public function markTranslationsAsDirty(ContentEntityInterface &$entity) {
  $profile = $this->lingotekConfiguration
    ->getEntityProfile($entity);
  if ($profile
    ->id() === Lingotek::PROFILE_DISABLED || $this
    ->getSourceStatus($entity) === Lingotek::STATUS_CANCELLED) {
    return FALSE;
  }
  $target_languages = $this->languageManager
    ->getLanguages();
  $entity_langcode = $entity
    ->getUntranslated()
    ->language()
    ->getId();

  // Only mark as out of date the current ones.
  $to_change = [
    Lingotek::STATUS_CURRENT,
  ];
  foreach ($target_languages as $langcode => $language) {
    if ($langcode != $entity_langcode && ($current_status = $this
      ->getTargetStatus($entity, $langcode))) {
      if (in_array($current_status, $to_change)) {
        $this
          ->setTargetStatus($entity, $langcode, Lingotek::STATUS_PENDING);
      }
    }
  }
}