public function LingotekConfigTranslationService::checkConfigTargetStatuses in Lingotek Translation 3.7.x
Same name and namespace in other branches
- 8 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
- 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigTargetStatuses()
Checks the status of the translations in the Lingotek service.
Parameters
string $mapper_id: The entity which status we want to check.
Return value
bool True if the entity is available for download.
Overrides LingotekConfigTranslationServiceInterface::checkConfigTargetStatuses
File
- src/
LingotekConfigTranslationService.php, line 1454
Class
- LingotekConfigTranslationService
- Service for managing Lingotek configuration translations.
Namespace
Drupal\lingotekCode
public function checkConfigTargetStatuses($mapper_id) {
$mapper = $this->mappers[$mapper_id];
/** @var \Drupal\lingotek\LingotekProfileInterface $profile */
$profile = $this->lingotekConfiguration
->getConfigProfile($mapper_id);
if ($profile
->id() === Lingotek::PROFILE_DISABLED || $this
->getConfigSourceStatus($mapper) === Lingotek::STATUS_CANCELLED) {
return FALSE;
}
$document_id = $this
->getConfigDocumentId($mapper);
$translation_statuses = $this->lingotek
->getDocumentTranslationStatuses($document_id);
$source_status = $this
->getConfigSourceStatus($mapper);
$statuses = [];
$languages = $this->languageManager
->getLanguages();
foreach ($languages as $language) {
$statuses[$language
->getId()] = $this
->getConfigTargetStatus($mapper, $language
->getId());
}
// Let's reset all statuses, but keep the source one.
$this
->clearConfigTargetStatuses($mapper_id);
foreach ($translation_statuses as $lingotek_locale => $progress) {
$drupal_language = $this->languageLocaleMapper
->getConfigurableLanguageForLocale($lingotek_locale);
if ($drupal_language == NULL) {
// languages existing in TMS, but not configured on Drupal
continue;
}
$langcode = $drupal_language
->id();
$current_target_status = $statuses[$langcode];
if (in_array($current_target_status, [
Lingotek::STATUS_UNTRACKED,
Lingotek::STATUS_DISABLED,
Lingotek::STATUS_EDITED,
Lingotek::STATUS_REQUEST,
Lingotek::STATUS_NONE,
Lingotek::STATUS_READY,
Lingotek::STATUS_PENDING,
Lingotek::STATUS_CANCELLED,
NULL,
])) {
if ($progress === Lingotek::STATUS_CANCELLED) {
$this
->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_CANCELLED);
}
elseif ($progress === Lingotek::PROGRESS_COMPLETE) {
$this
->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_READY);
}
else {
if (!$profile
->hasDisabledTarget($langcode)) {
$this
->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_PENDING);
}
else {
$this
->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_DISABLED);
}
}
}
if ($source_status !== Lingotek::STATUS_CURRENT && $statuses[$langcode] === Lingotek::STATUS_EDITED && $langcode !== $mapper
->getLangcode()) {
$this
->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_EDITED);
}
if ($source_status === Lingotek::STATUS_CURRENT && $statuses[$langcode] === Lingotek::STATUS_CURRENT && $langcode !== $mapper
->getLangcode()) {
$this
->setConfigTargetStatus($mapper, $langcode, Lingotek::STATUS_CURRENT);
}
}
if ($this
->getConfigSourceStatus($mapper) == Lingotek::STATUS_DISABLED) {
$this
->setConfigTargetStatuses($mapper, Lingotek::STATUS_DISABLED);
}
}