You are here

public function LingotekInterfaceTranslationService::cancelDocument in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 3.2.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocument()
  2. 3.3.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocument()
  3. 3.4.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocument()
  4. 3.5.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocument()
  5. 3.6.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocument()
  6. 3.7.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocument()
  7. 3.8.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocument()

Cancels a document from the server.

Parameters

string $component: The component which we want to cancel.

Return value

string The component.

Overrides LingotekInterfaceTranslationServiceInterface::cancelDocument

2 calls to LingotekInterfaceTranslationService::cancelDocument()
LingotekInterfaceTranslationService::deleteAllMetadata in src/LingotekInterfaceTranslationService.php
LingotekInterfaceTranslationService::deleteMetadata in src/LingotekInterfaceTranslationService.php
Deletes all local metadata related to an component.

File

src/LingotekInterfaceTranslationService.php, line 857

Class

LingotekInterfaceTranslationService
Service for managing Lingotek interface translations.

Namespace

Drupal\lingotek

Code

public function cancelDocument($component) {
  $result = FALSE;
  $doc_id = $this
    ->getDocumentId($component);
  if ($doc_id) {
    try {
      $result = $this->lingotek
        ->cancelDocument($doc_id);
      $this
        ->setDocumentId($component, 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' => $component,
        '%doc_id' => $doc_id,
      ]);
      $this
        ->setDocumentId($component, NULL);
    } catch (LingotekDocumentNotFoundException $exception) {
      $this
        ->setDocumentId($component, NULL);
      $this
        ->deleteMetadata($component);
      throw $exception;
    } catch (LingotekDocumentNotFoundException $exception) {
      $this
        ->setDocumentId($component, NULL);
      throw $exception;
    }
  }
  $this
    ->setSourceStatus($component, Lingotek::STATUS_CANCELLED);
  $this
    ->setTargetStatuses($component, Lingotek::STATUS_CANCELLED);
  return $result;
}