public static function LingotekConfigSet::bulkGetSetId in Lingotek Translation 7.7
2 calls to LingotekConfigSet::bulkGetSetId()
- drush_lingotek_push in ./
lingotek.drush.inc - Callback function for drush command batch upload translatable content
- lingotek_config_upload_selected in ./
lingotek.config.inc
File
- lib/
Drupal/ lingotek/ LingotekConfigSet.php, line 197 - Defines LingotekConfigSet.
Class
- LingotekConfigSet
- A class wrapper for Lingotek-specific behavior on ConfigSets.
Code
public static function bulkGetSetId($lid_map) {
$set_ids = array();
foreach ($lid_map as $textgroup => $lids) {
$open_set_id = self::getOpenSet($textgroup);
if ($open_set_id === FALSE) {
$open_set_id = self::createSet($textgroup);
}
$query = db_select('lingotek_config_map', 'lcm');
$query
->addField('lcm', 'set_id');
$query
->addField('lcm', 'lid');
$query
->condition('lid', $lids, "IN");
$result = $query
->execute()
->fetchAllAssoc('lid');
$insert = db_insert('lingotek_config_map');
$insert
->fields(array(
'lid',
'set_id',
));
$count = 0;
foreach ($lids as $lid) {
if ($count === LINGOTEK_CONFIG_SET_SIZE) {
$open_set_id = self::createSet($textgroup);
$count = 0;
}
if (!isset($result[$lid])) {
$insert
->values(array(
'lid' => $lid,
'set_id' => $open_set_id,
));
$set_ids[$open_set_id] = $open_set_id;
}
else {
$set_ids[$result[$lid]->set_id] = $result[$lid]->set_id;
}
$count++;
}
$insert
->execute();
}
return $set_ids;
}