You are here

public static function LingotekEntity::loadByLingotekDocumentId in Lingotek Translation 7.7

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

Loads a LingotekNode by Lingotek Document ID.

Parameters

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

Return value

mixed A LingotekNode object on success, FALSE on failure.

2 calls to LingotekEntity::loadByLingotekDocumentId()
LingotekApi::downloadDocument in lib/Drupal/lingotek/LingotekApi.php
Downloads the translated document for the specified document and language.
update_pending_sources in ./lingotek.sync.inc

File

lib/Drupal/lingotek/LingotekEntity.php, line 98
Defines LingotekEntity.

Class

LingotekEntity
A class wrapper for Lingotek-specific behavior on nodes.

Code

public static function loadByLingotekDocumentId($lingotek_document_id) {
  $entity = FALSE;
  $query = db_select('lingotek_entity_metadata', 'l')
    ->fields('l');
  $query
    ->condition('entity_key', 'document_id');
  $query
    ->condition('value', $lingotek_document_id);
  $result = $query
    ->execute();
  if ($record = $result
    ->fetchAssoc()) {
    $id = $record['entity_id'];
    $entity_type = $record['entity_type'];
  }
  if ($id) {
    $entity = self::load($id, $entity_type);
  }
  return $entity;
}