public static function LingotekComment::loadByLingotekDocumentId in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.2 lib/Drupal/lingotek/LingotekComment.php \LingotekComment::loadByLingotekDocumentId()
- 7.3 lib/Drupal/lingotek/LingotekComment.php \LingotekComment::loadByLingotekDocumentId()
Loads a LingotekComment by Lingotek Document ID.
Parameters
string $lingotek_document_id: The Document ID whose corresponding comment 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 LingotekComment object on success, FALSE on failure.
1 call to LingotekComment::loadByLingotekDocumentId()
- lingotek_notifications in ./
lingotek.sync.inc - Registers the site translation notfication callback.
File
- lib/
Drupal/ lingotek/ LingotekComment.php, line 106 - Defines LingotekComment.
Class
- LingotekComment
- A class wrapper for Lingotek-specific behavior on Comments.
Code
public static function loadByLingotekDocumentId($lingotek_document_id, $source_language_code, $lingotek_project_id) {
$comment = FALSE;
// Get all Comments in the system associated with the document ID.
$query = db_select('lingotek_entity_metadata', 'meta')
->fields('meta', array(
'entity_id',
))
->condition('entity_key', 'document_id')
->condition('entity_type', 'comment')
->condition('value', $lingotek_document_id);
$results = $query
->execute();
$target_entity_ids = array();
foreach ($results as $result) {
$target_entity_ids[] = $result->entity_id;
}
// Get the results that are associated with the passed Lingotek project ID.
// Lingotek Document IDs are not unique across projects.
if (!empty($target_entity_ids)) {
$in_project_results = db_select('lingotek_entity_metadata', 'meta')
->fields('meta', array(
'entity_id',
))
->condition('entity_id', $target_entity_ids, 'IN')
->condition('entity_key', 'project_id')
->condition('entity_type', 'comment')
->condition('value', $lingotek_project_id)
->execute()
->fetchAll();
if (count($in_project_results)) {
$comment = self::loadById($in_project_results[0]->entity_id);
}
}
return $comment;
}