You are here

public function SmartlingTranslator::isReadyForDownload in TMGMT Translator Smartling 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::isReadyForDownload()
  2. 8.2 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::isReadyForDownload()
  3. 8.3 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::isReadyForDownload()

Checks if file is ready for download.

Parameters

JobInterface $job:

Return value

bool

File

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

Class

SmartlingTranslator
Smartling translator plugin.

Namespace

Drupal\tmgmt_smartling\Plugin\tmgmt\Translator

Code

public function isReadyForDownload(JobInterface $job) {
  try {
    $api = $this
      ->getSmartlingApi($job
      ->getTranslator());
    $filename = $this
      ->getFileName($job);
    $locale = $job
      ->getRemoteTargetLanguage();
    $request_result = $api
      ->getStatus($filename, $locale);
  } catch (\Exception $e) {
    watchdog_exception('tmgmt_smartling', $e);
    return FALSE;
  }
  \Drupal::logger('tmgmt_smartling')
    ->info('Check status for file: @filename found @approved approved words and @completed completed ones', [
    '@filename' => $filename,
    '@approved' => @$request_result['approvedStringCount'],
    '@completed' => @$request_result['completedStringCount'],
  ]);
  return $request_result['approvedStringCount'] > 0 && $request_result['approvedStringCount'] === $request_result['completedStringCount'];
}