public function LingotekContentTranslationService::setTargetStatus in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.1.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.2.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.3.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.6.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 3.8.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
Sets the translation status of a given entity translation for a locale.
Parameters
ContentEntityInterface &$entity: The entity which status we want to change.
string $locale: Lingotek translation language which we want to modify.
int $status: Status of the translation. Use Lingotek constants.
bool $save: If FALSE, the entity is not saved yet. Defaults to TRUE.
Return value
Overrides LingotekContentTranslationServiceInterface::setTargetStatus
8 calls to LingotekContentTranslationService::setTargetStatus()
- LingotekContentTranslationService::addTarget in src/
LingotekContentTranslationService.php - Request a translation for a given entity in the given locale.
- LingotekContentTranslationService::checkTargetStatus in src/
LingotekContentTranslationService.php - Gets the current status of the target translation.
- LingotekContentTranslationService::checkTargetStatuses in src/
LingotekContentTranslationService.php - Gets the current status of all the target translations.
- LingotekContentTranslationService::downloadDocument in src/
LingotekContentTranslationService.php - Downloads a document from the Lingotek service for a given locale.
- LingotekContentTranslationService::markTranslationsAsDirty in src/
LingotekContentTranslationService.php - Marks the translation status as dirty if they exist.
File
- src/
LingotekContentTranslationService.php, line 242 - Contains \Drupal\lingotek\LingotekContentTranslationService.
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
public function setTargetStatus(ContentEntityInterface &$entity, $langcode, $status, $save = TRUE) {
$set = FALSE;
if ($entity
->hasField('lingotek_translation_status') && count($entity->lingotek_translation_status) > 0) {
foreach ($entity->lingotek_translation_status
->getIterator() as $delta => $value) {
if ($value->language == $langcode) {
$value->value = $status;
$set = true;
}
}
}
if (!$set && $entity
->hasField('lingotek_translation_status')) {
$entity->lingotek_translation_status
->appendItem([
'language' => $langcode,
'value' => $status,
]);
$set = TRUE;
}
if ($set && $save) {
// If the entity supports revisions, ensure we don't create a new one.
if ($entity
->getEntityType()
->hasKey('revision')) {
$entity
->setNewRevision(FALSE);
}
$entity->lingotek_processed = TRUE;
$entity
->save();
}
return $entity;
}