You are here

protected function LingotekApi::getCommentCreateWithTargetsParams in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 7.3 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::getCommentCreateWithTargetsParams()
  2. 7.4 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::getCommentCreateWithTargetsParams()

Gets the comment-specific parameters for use in a createContentDocumentWithTargets API call.

Parameters

LingotekComment: The comment entity to be translated.

Return value

array An array of API parameter values.

1 call to LingotekApi::getCommentCreateWithTargetsParams()
LingotekApi::getCreateWithTargetsParams in lib/Drupal/lingotek/LingotekApi.php
Collects the entity-specific parameter values for a document create API call.

File

lib/Drupal/lingotek/LingotekApi.php, line 187
Defines Drupal\lingotek\LingotekApi

Class

LingotekApi
@file Defines Drupal\lingotek\LingotekApi

Code

protected function getCommentCreateWithTargetsParams(LingotekComment $comment) {
  $targets = Lingotek::availableLanguageTargets();
  foreach ($targets as $index => $target) {
    if ($target == Lingotek::convertDrupal2Lingotek($comment->language)) {
      unset($targets[$index]);
      break;
    }
  }
  $parameters = array(
    'projectId' => variable_get('lingotek_project', NULL),
    'documentName' => 'comment - ' . $comment->cid,
    'documentDesc' => 'comment ' . $comment->cid . ' on node ' . $comment->nid,
    'format' => $this
      ->xmlFormat(),
    'applyWorkflow' => 'true',
    'workflowId' => variable_get('lingotek_translate_comments_workflow_id', NULL),
    'sourceLanguage' => Lingotek::convertDrupal2Lingotek($comment->language),
    'tmVaultId' => variable_get('lingotek_vault', 1),
    'content' => $comment
      ->documentLingotekXML(),
    'targetAsJSON' => drupal_json_encode(array_values($targets)),
    'note' => url('node/' . $comment->nid, array(
      'absolute' => TRUE,
      'alias' => TRUE,
    )),
  );
  $this
    ->addAdvancedParameters($parameters, $comment);
  return $parameters;
}