You are here

public function LocalTranslator::requestJobItemsTranslation in Translation Management Tool 8

Requests the translation of a JobItem.

Parameters

JobItemInterface[] $job_items: The JobItem we want to translate.

Overrides ContinuousTranslatorInterface::requestJobItemsTranslation

1 call to LocalTranslator::requestJobItemsTranslation()
LocalTranslator::requestTranslation in translators/tmgmt_local/src/Plugin/tmgmt/Translator/LocalTranslator.php
@abstract

File

translators/tmgmt_local/src/Plugin/tmgmt/Translator/LocalTranslator.php, line 44

Class

LocalTranslator
Drupal user provider.

Namespace

Drupal\tmgmt_local\Plugin\tmgmt\Translator

Code

public function requestJobItemsTranslation(array $job_items) {

  /** @var \Drupal\tmgmt\Entity\Job $job */
  $job = reset($job_items)
    ->getJob();
  $tuid = $job
    ->getSetting('translator');

  // Create local task for this job.

  /** @var \Drupal\tmgmt_local\LocalTaskInterface $local_task */
  $local_task = LocalTask::create(array(
    'uid' => $job
      ->getOwnerId(),
    'tuid' => $tuid,
    'tjid' => $job
      ->id(),
    'title' => $job
      ->label(),
  ));

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

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