You are here

public function LingotekConfigTranslationService::checkConfigSourceStatus in Lingotek Translation 3.7.x

Same name and namespace in other branches
  1. 8 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  2. 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  3. 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  4. 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  5. 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  6. 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  7. 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  8. 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  9. 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  10. 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()
  11. 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::checkConfigSourceStatus()

Checks the source is uploaded correctly.

Parameters

string $mapper_id: The entity which status we want to check.

Return value

bool True if the entity is uploaded successfully.

Overrides LingotekConfigTranslationServiceInterface::checkConfigSourceStatus

File

src/LingotekConfigTranslationService.php, line 1223

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function checkConfigSourceStatus($mapper_id) {
  $mapper = $this->mappers[$mapper_id];
  $profile = $this->lingotekConfiguration
    ->getConfigProfile($mapper_id);
  if ($profile
    ->id() === Lingotek::PROFILE_DISABLED || $this
    ->getConfigSourceStatus($mapper) === Lingotek::STATUS_CANCELLED) {
    return FALSE;
  }
  $document_id = $this
    ->getConfigDocumentId($mapper);
  if ($document_id) {
    try {
      $status = $this->lingotek
        ->getDocumentStatus($document_id);
    } catch (LingotekDocumentLockedException $exception) {
      $this
        ->setConfigDocumentId($mapper, $exception
        ->getNewDocumentId());
      throw $exception;
    } catch (LingotekDocumentNotFoundException $exception) {
      if ($this
        ->checkConfigUploadProcessId($mapper_id)) {

        // 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
          ->setConfigDocumentId($mapper, NULL);
        $this
          ->deleteConfigMetadata($mapper_id);
        throw $exception;
      }
      else {
        return FALSE;
      }
    } catch (LingotekDocumentArchivedException $exception) {
      $this
        ->setConfigDocumentId($mapper, NULL);
      $this
        ->deleteConfigMetadata($mapper_id);
      throw $exception;
    } catch (LingotekPaymentRequiredException $exception) {
      throw $exception;
    } catch (LingotekApiException $exception) {
      throw $exception;
    }
    if ($status) {
      $this
        ->setConfigSourceStatus($mapper, Lingotek::STATUS_CURRENT);
      return TRUE;
    }
  }
  if ($this
    ->getConfigSourceStatus($mapper) == Lingotek::STATUS_DISABLED) {
    $this
      ->setConfigTargetStatuses($mapper, Lingotek::STATUS_DISABLED);
  }
  return FALSE;
}