public function LingotekConfigTranslationService::cancelDocument in Lingotek Translation 3.7.x
Same name and namespace in other branches
- 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
- 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::cancelDocument()
Cancels a document from the server.
Parameters
\Drupal\Core\Config\Entity\ConfigEntityInterface &$entity: The entity which we want to cancel.
Return value
\Drupal\Core\Config\Entity\ConfigEntityInterface The entity.
Overrides LingotekConfigTranslationServiceInterface::cancelDocument
1 call to LingotekConfigTranslationService::cancelDocument()
- LingotekConfigTranslationService::deleteMetadata in src/
LingotekConfigTranslationService.php - Deletes metadata.
File
- src/
LingotekConfigTranslationService.php, line 873
Class
- LingotekConfigTranslationService
- Service for managing Lingotek configuration translations.
Namespace
Drupal\lingotekCode
public function cancelDocument(ConfigEntityInterface &$entity) {
$result = FALSE;
$doc_id = $this
->getDocumentId($entity);
if ($doc_id) {
try {
$result = $this->lingotek
->cancelDocument($doc_id);
$this->lingotekConfiguration
->setConfigEntityProfile($entity, NULL);
$this
->setDocumentId($entity, NULL);
} catch (LingotekDocumentAlreadyCompletedException $exception) {
\Drupal::logger('lingotek')
->warning('The document %label (%doc_id) was not cancelled on the TMS side as it was already completed.', [
'%label' => $entity
->label(),
'%doc_id' => $doc_id,
]);
$this->lingotekConfiguration
->setConfigEntityProfile($entity, NULL);
$this
->setDocumentId($entity, NULL);
} catch (LingotekDocumentArchivedException $exception) {
$this
->messenger()
->addError($this
->t('Document %label has been archived. Please upload again.', [
'%label' => $entity
->label(),
]));
} catch (LingotekDocumentNotFoundException $exception) {
$this
->setDocumentId($entity, NULL);
$this
->deleteMetadata($entity);
throw $exception;
}
}
$this
->setSourceStatus($entity, Lingotek::STATUS_CANCELLED);
$this
->setTargetStatuses($entity, Lingotek::STATUS_CANCELLED);
return $result;
}