You are here

public function GlobalLinkTranslator::fetchJobs 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::fetchJobs()

Fetches translations for job items of a given job.

Parameters

Job $job: A job containing job items that translations will be fetched for.

Return value

bool Returns TRUE if there are error messages during the process of retrieving translations. Otherwise FALSE.

File

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

Class

GlobalLinkTranslator
GlobalLink translation plugin controller.

Namespace

Drupal\globallink\Plugin\tmgmt\Translator

Code

public function fetchJobs(Job $job) {
  $this
    ->setTranslator($job
    ->getTranslator());
  $completed_translations = $this
    ->getCompletedTranslations($this->translator);

  // Reorganise completed translations by uuid.
  $translations_imported = FALSE;
  foreach ($completed_translations as $completed_translation) {
    if ($completed_translation->clientIdentifier == $job
      ->uuid()) {
      $this
        ->retrieveTranslation($completed_translation->ticket, $job);
      $translations_imported = TRUE;
    }
  }
  if (!$translations_imported) {
    $this
      ->messenger()
      ->addStatus(t('No translations available for this job at the moment.'));
  }
}