You are here

public function GlobalLinkTranslator::getCompletedTranslations in GlobalLink Connect for Drupal 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/tmgmt/Translator/GlobalLinkTranslator.php \Drupal\globallink\Plugin\tmgmt\Translator\GlobalLinkTranslator::getCompletedTranslations()

Get completed translations for a specific translator project.

Parameters

TranslatorInterface $translator: The translator interface

Return value

\PDTarget[] Array of PDTarget objects.

1 call to GlobalLinkTranslator::getCompletedTranslations()
GlobalLinkTranslator::fetchJobs in src/Plugin/tmgmt/Translator/GlobalLinkTranslator.php
Fetches translations for job items of a given job.

File

src/Plugin/tmgmt/Translator/GlobalLinkTranslator.php, line 552

Class

GlobalLinkTranslator
GlobalLink translation plugin controller.

Namespace

Drupal\globallink\Plugin\tmgmt\Translator

Code

public function getCompletedTranslations($translator) {
  $completed_translations = [];
  $adapter = $this->glExchangeAdapter;
  $settings = $translator
    ->getSettings();
  $pd_config = $adapter
    ->getPDConfig($settings);
  $glexchange = $adapter
    ->getGlExchange($pd_config);
  try {
    $project = $glexchange
      ->getProject($translator
      ->getSetting('pd_projectid'));
    $completed_translations = $glexchange
      ->getCompletedTargetsByProject($project, $adapter::COMPLETED_BY_PROJECT_MAX_RESULT);
  } catch (\Exception $e) {
    $this->logger
      ->error('Could not retrieve completed translations because of the following error: @error', [
      '@error' => $e
        ->getMessage(),
    ]);
    tmgmt_message_create('Failed downloading translation. Message error: @error', [
      '@error' => $e
        ->getMessage(),
    ], [
      'type' => 'error',
    ]);
  }
  return $completed_translations;
}