You are here

protected function SmartlingTranslator::handleSmartlingApiException in TMGMT Translator Smartling 8.3

1 call to SmartlingTranslator::handleSmartlingApiException()
SmartlingTranslator::isReadyForDownload in src/Plugin/tmgmt/Translator/SmartlingTranslator.php
Checks if file is ready for download.

File

src/Plugin/tmgmt/Translator/SmartlingTranslator.php, line 759
Contains \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator.

Class

SmartlingTranslator
Smartling translator plugin.

Namespace

Drupal\tmgmt_smartling\Plugin\tmgmt\Translator

Code

protected function handleSmartlingApiException(SmartlingApiException $e, JobInterface $job) {
  if (!empty($e
    ->getErrorsByKey('file.not.found'))) {
    $filename = $this
      ->getFileName($job);
    $message = 'The file @filename could not be found in Smartling. The job @job_id is rejected. Please resubmit TMGMT Job in order to upload file in Smartling.';
    $substitutions = [
      '@filename' => $filename,
      '@job_id' => $job
        ->id(),
    ];
    $job
      ->rejected($message, $substitutions);
    $this->logger
      ->warning($message, $substitutions);
  }
  if (!empty($e
    ->getErrorsByKey('locale.not.found'))) {
    $locale = $job
      ->getRemoteTargetLanguage();
    $message = 'Specified locale \'@locale\' is not available for the project. The job @job_id is rejected.';
    $substitutions = [
      '@locale' => $locale,
      '@job_id' => $job
        ->id(),
    ];
    $job
      ->rejected($message, $substitutions);
    $this->logger
      ->warning($message, $substitutions);
  }
  if (!empty($e
    ->getErrorsByKey('locale.disabled'))) {
    $locale = $job
      ->getRemoteTargetLanguage();
    $message = 'Specified locale \'@locale\' is disabled. The job @job_id is rejected.';
    $substitutions = [
      '@locale' => $locale,
      '@job_id' => $job
        ->id(),
    ];
    $job
      ->rejected($message, $substitutions);
    $this->logger
      ->warning($message, $substitutions);
  }
  watchdog_exception('tmgmt_smartling', $e);
}