You are here

public static function LingotekConfigChunk::loadByLingotekDocumentId in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.3 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::loadByLingotekDocumentId()
  2. 7.5 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::loadByLingotekDocumentId()

Loads a LingotekConfigChunk by Lingotek Document ID.

Parameters

string $lingotek_document_id: The Document ID whose corresponding chunk should be loaded.

string $lingotek_language_code: The language code associated with the Lingotek Document ID.

int $lingotek_project_id: The Lingotek project ID associated with the Lingotek Document ID.

Return value

mixed A LingotekConfigChunk object on success, FALSE on failure.

2 calls to LingotekConfigChunk::loadByLingotekDocumentId()
lingotek_get_and_update_target_progress in ./lingotek.sync.inc
Updates the 'target_sync_progress_[lang-code]' field for every target in the lingotek table with the overall progress returned by TMS
lingotek_notifications in ./lingotek.sync.inc
Registers the site translation notfication callback.

File

lib/Drupal/lingotek/LingotekConfigChunk.php, line 380
Defines LingotekConfigChunk.

Class

LingotekConfigChunk
A class wrapper for Lingotek-specific behavior on ConfigChunks.

Code

public static function loadByLingotekDocumentId($lingotek_document_id, $source_language_code, $lingotek_project_id) {
  $chunk = FALSE;

  // Get the Chunk entries in the system associated with the document ID.
  $query = db_select('lingotek_config_metadata', 'meta')
    ->fields('meta', array(
    'id',
  ))
    ->condition('config_key', 'document_id')
    ->condition('value', $lingotek_document_id);
  $results = $query
    ->execute();
  $target_ids = array();
  foreach ($results as $result) {
    $target_ids[] = $result->id;
  }

  // Get the results that are associated with the passed Lingotek project ID.
  // Lingotek Document IDs are not unique across projects.
  if (!empty($target_ids)) {
    $in_project_results = db_select('lingotek_config_metadata', 'meta')
      ->fields('meta', array(
      'id',
    ))
      ->condition('id', $target_ids, 'IN')
      ->condition('config_key', 'project_id')
      ->condition('value', $lingotek_project_id)
      ->execute()
      ->fetchAll();
    if (count($in_project_results)) {
      $chunk = self::loadById($in_project_results[0]->id);
    }
  }
  return $chunk;
}