You are here

function GLExchange::downloadTranslationKit in GlobalLink Connect for Drupal 7.7

File

gl_ws/glc/GLExchange.php, line 314

Class

GLExchange

Code

function downloadTranslationKit($submissionWorkflowInfo) {
  $repositoryItems = array();
  $workflowRequestTickets = array();
  $workflowRequest = $this
    ->_createWorkflowRequest($submissionWorkflowInfo);
  $downloadWorkflowRequestTicket = $this->workflowService
    ->download($workflowRequest)->return;
  array_push($workflowRequestTickets, $downloadWorkflowRequestTicket);

  // Ping server for checking if download has finished
  while (count($workflowRequestTickets) > 0) {
    sleep(DELAY_TIME);
    foreach ($workflowRequestTickets as &$workflowRequestTicket) {
      $downloadActionResult = $this->workflowService
        ->checkDownloadAction($workflowRequestTicket)->return;
      if ($downloadActionResult->processingFinished->booleanValue) {
        $repositoryItem = $downloadActionResult->repositoryItem;
        array_push($repositoryItems, $repositoryItem);
        unset($workflowRequestTickets[$workflowRequestTicket]);
      }
    }
  }
  return $repositoryItems;
}