You are here

public static function LingotekEntity::loadByLingotekDocumentId in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.7 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.

File

lib/Drupal/lingotek/LingotekEntity.php, line 88
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::loadById($id, $entity_type);
  }
  return $entity;
}