public function LingotekContentTranslationService::setTargetStatus in Lingotek Translation 3.0.x
Same name and namespace in other branches
- 8 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setTargetStatus()
- 4.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
\Drupal\Core\Entity\ContentEntityInterface &$entity: The entity which status we want to change.
string $langcode: Language code 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
\Drupal\Core\Entity\ContentEntityInterface
Overrides LingotekContentTranslationServiceInterface::setTargetStatus
12 calls to LingotekContentTranslationService::setTargetStatus()
- LingotekContentTranslationService::addTarget in src/
LingotekContentTranslationService.php - Request a translation for a given entity in the given locale.
- LingotekContentTranslationService::cancelDocumentTarget in src/
LingotekContentTranslationService.php - Cancels 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::clearTargetStatuses in src/
LingotekContentTranslationService.php - Clear the target statuses.
File
- src/
LingotekContentTranslationService.php, line 347
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
public function setTargetStatus(ContentEntityInterface &$entity, $langcode, $status, $save = TRUE) {
$set = FALSE;
if (!$entity->lingotek_metadata->entity) {
$entity->lingotek_metadata->entity = LingotekContentMetadata::loadByTargetId($entity
->getEntityTypeId(), $entity
->id());
}
$metadata =& $entity->lingotek_metadata->entity;
if ($metadata
->hasField('translation_status') && count($metadata->translation_status) > 0) {
foreach ($metadata->translation_status
->getIterator() as $delta => $value) {
if ($value->language == $langcode) {
$value->value = $status;
$set = TRUE;
}
}
}
if (!$set && $metadata
->hasField('translation_status')) {
$metadata->translation_status
->appendItem([
'language' => $langcode,
'value' => $status,
]);
$set = TRUE;
}
if ($set) {
$entity->lingotek_processed = TRUE;
$metadata
->save();
}
return $entity;
}