You are here

public function Lingotek::addTarget in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  2. 4.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  3. 3.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  4. 3.1.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  5. 3.2.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  6. 3.3.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  7. 3.4.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  8. 3.5.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  9. 3.6.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  10. 3.7.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()
  11. 3.8.x src/Lingotek.php \Drupal\lingotek\Lingotek::addTarget()

Requests a translation to the Lingotek service.

Parameters

string $doc_id: The document id to translate.

string $locale: The Lingotek locale to request.

\Drupal\lingotek\LingotekProfileInterface $profile: The profile being used.

Return value

mixed

Overrides LingotekInterface::addTarget

File

src/Lingotek.php, line 244
Contains \Drupal\lingotek\Lingotek.

Class

Lingotek

Namespace

Drupal\lingotek

Code

public function addTarget($doc_id, $locale, LingotekProfileInterface $profile = NULL) {
  $workflow_id = NULL;
  $drupal_language = $this->languageLocaleMapper
    ->getConfigurableLanguageForLocale($locale);
  if ($profile !== NULL && ($workflow_id = $profile
    ->getWorkflowForTarget($drupal_language
    ->getId()))) {
    if ($workflow_id === 'default') {
      $workflow_id = $this
        ->get('default.workflow');
    }
  }
  $response = $this->api
    ->addTranslation($doc_id, $locale, $workflow_id);
  if ($response
    ->getStatusCode() == Response::HTTP_CREATED) {
    return TRUE;
  }
  return FALSE;
}