You are here

public function LingotekApi::addContentDocumentWithTargets in Lingotek Translation 7.2

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

Adds a Document and one or more Translation Targets to the Lingotek platform. (only used by comments currently)

Parameters

LingotekTranslatableEntity $entity: A Drupal entity.

File

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

Class

LingotekApi
@file Defines Drupal\lingotek\LingotekApi

Code

public function addContentDocumentWithTargets(LingotekTranslatableEntity $entity) {
  global $_lingotek_locale;
  $success = FALSE;
  $parameters = $this
    ->getCreateWithTargetsParams($entity);
  if ($result = $this
    ->request('addContentDocumentWithTargets', $parameters)) {
    $entity
      ->setMetadataValue('document_id', $result->id);

    // Comments are all associated with the configured "default" Lingotek project.
    // Nodes can have their projects selected on a per-node basis, and will need
    // separate consideration if addContentDocumentWithTargets is used for them
    // in the future.
    if (get_class($entity) == 'LingotekComment') {
      $entity
        ->setMetadataValue('project_id', variable_get('lingotek_project'));
    }
    $success = TRUE;
  }
  return $success;
}