public static function LingotekSync::getTargetsByStatus in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.4 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getTargetsByStatus()
- 7.5 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getTargetsByStatus()
getDocIdTargetsByStatus
Parameters
status (e.g., LingotekSync::READY):
Return value
an array of associate arrays. Each associate array will have a 'nid' (e.g., 5), 'locale' (e.g., 'de_DE'), and optionally 'doc_id' (e.g., 46677222-b5ec-47d5-880e-24632feffaf5)
1 call to LingotekSync::getTargetsByStatus()
File
- lib/
Drupal/ lingotek/ LingotekSync.php, line 154 - LingotekSync
Class
- LingotekSync
- A utility class for Lingotek Syncing.
Code
public static function getTargetsByStatus($entity_type, $status, $include_doc_ids = FALSE) {
$target_language_search = '%';
$query = db_select('lingotek_entity_metadata', 'l');
$query
->fields('l', array(
'entity_id',
'entity_key',
'value',
));
$query
->condition('entity_type', $entity_type);
$query
->condition('entity_key', 'target_sync_status_' . $target_language_search, 'LIKE');
$query
->condition('value', $status);
$result = $query
->execute();
$records = $result
->fetchAll();
//$result->fetchAllAssoc('nid');
// build nid_doc_map (if needed)
if ($include_doc_ids) {
$nid_doc_map = array();
foreach ($records as $record) {
if (!key_exists($record->entity_id, $nid_doc_map)) {
$doc_id = self::getDocIdFrom($record->entity_id);
$nid_doc_map[$record->entity_id] = $doc_id;
}
}
}
$targets = array();
foreach ($records as $record) {
$doc_target = array(
'id' => $record->entity_id,
'doc_id' => $include_doc_ids ? $nid_doc_map[$record->entity_id] : NULL,
'locale' => str_replace('target_sync_status_', '', $record->entity_key),
);
$targets[] = $doc_target;
}
return $targets;
}