public function LingotekConfigTranslationService::setTargetStatuses in Lingotek Translation 8.2
Same name and namespace in other branches
- 8 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.7.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
- 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setTargetStatuses()
Sets the translation status of all translations of a given entity.
Parameters
\Drupal\Core\Config\ConfigEntityInterface &$entity: 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::setTargetStatuses
10 calls to LingotekConfigTranslationService::setTargetStatuses()
- LingotekConfigTranslationService::addTarget in src/
LingotekConfigTranslationService.php - Request a translation for a given entity in the given locale.
- LingotekConfigTranslationService::cancelDocument in src/
LingotekConfigTranslationService.php - Cancels a document from the server.
- LingotekConfigTranslationService::cancelDocumentTarget in src/
LingotekConfigTranslationService.php - Cancels a translation for a given entity in the given locale.
- LingotekConfigTranslationService::checkSourceStatus in src/
LingotekConfigTranslationService.php - Checks the source is uploaded correctly.
- LingotekConfigTranslationService::checkTargetStatus in src/
LingotekConfigTranslationService.php - Checks the status of the translation in the Lingotek service.
File
- src/
LingotekConfigTranslationService.php, line 245
Class
- LingotekConfigTranslationService
- Service for managing Lingotek configuration translations.
Namespace
Drupal\lingotekCode
public function setTargetStatuses(ConfigEntityInterface &$entity, $status) {
$target_languages = $this->languageManager
->getLanguages();
$entity_langcode = $entity
->language()
->getId();
foreach ($target_languages as $langcode => $language) {
if ($langcode != $entity_langcode && ($current_status = $this
->getTargetStatus($entity, $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
->setTargetStatus($entity, $langcode, $status);
}
elseif ($current_status == Lingotek::STATUS_EDITED && in_array($status, [
Lingotek::STATUS_CURRENT,
Lingotek::STATUS_PENDING,
])) {
$this
->setTargetStatus($entity, $langcode, $status);
}
if ($status === Lingotek::STATUS_CANCELLED) {
$this
->setTargetStatus($entity, $langcode, $status);
}
if ($status === Lingotek::STATUS_DISABLED) {
$this
->setTargetStatus($entity, $langcode, $status);
}
}
}
}