You are here

public function TMGMTLocalTranslatorPluginController::requestTranslation in Translation Management Tool 7

@abstract

Submits the translation request and sends it to the translation provider.

Parameters

TMGMTJob $job: The job that should be submitted.

Overrides TMGMTTranslatorPluginControllerInterface::requestTranslation

File

translators/tmgmt_local/includes/tmgmt_local.plugin.inc, line 18
Provides the user translator plugin controller.

Class

TMGMTLocalTranslatorPluginController
Local translator plugin controller.

Code

public function requestTranslation(TMGMTJob $job) {
  $tuid = $job
    ->getSetting('translator');

  // Create local task for this job.
  $local_task = tmgmt_local_task_create(array(
    'uid' => $job->uid,
    'tuid' => $tuid,
    'tjid' => $job->tjid,
    'title' => t('Task for !label', array(
      '!label' => $job
        ->defaultLabel(),
    )),
  ));

  // If we have translator then switch to pending state.
  if ($tuid) {
    $local_task->status = TMGMT_LOCAL_TASK_STATUS_PENDING;
  }
  $local_task
    ->save();

  // Create task items.
  foreach ($job
    ->getItems() as $item) {
    $local_task
      ->addTaskItem($item);
  }

  // The translation job has been successfully submitted.
  $job
    ->submitted();
}