You are here

public function LingotekInterfaceTranslationService::checkSourceStatus in Lingotek Translation 3.7.x

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

Checks the source is uploaded correctly.

Parameters

string $component: The component which status we want to check.

Return value

bool True if the component is uploaded successfully.

Overrides LingotekInterfaceTranslationServiceInterface::checkSourceStatus

File

src/LingotekInterfaceTranslationService.php, line 140

Class

LingotekInterfaceTranslationService
Service for managing Lingotek interface translations.

Namespace

Drupal\lingotek

Code

public function checkSourceStatus($component) {
  $document_id = $this
    ->getDocumentId($component);
  if ($document_id) {

    // Document has successfully imported.
    try {
      $status = $this->lingotek
        ->getDocumentStatus($document_id);
    } catch (LingotekDocumentLockedException $exception) {
      $this
        ->setDocumentId($component, $exception
        ->getNewDocumentId());
      throw $exception;
    } catch (LingotekDocumentNotFoundException $exception) {
      if ($this
        ->checkUploadProcessId($component)) {

        // If the document was not found and the process completed means that
        // the document might have been deleted afterwards.
        // We check for timeout to set an error if needed.
        $this
          ->setDocumentId($component, NULL);
        $this
          ->deleteMetadata($component);
        throw $exception;
      }
      else {
        return FALSE;
      }
    } catch (LingotekDocumentArchivedException $exception) {
      $this
        ->setDocumentId($component, NULL);
      $this
        ->deleteMetadata($component);
      throw $exception;
    } catch (LingotekPaymentRequiredException $exception) {
      throw $exception;
    } catch (LingotekApiException $exception) {
      throw $exception;
    }
    if ($status) {
      $this
        ->setSourceStatus($component, Lingotek::STATUS_CURRENT);
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
  return FALSE;
}