function lingotek_sync_upload_config_set in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lingotek.batch.inc \lingotek_sync_upload_config_set()
Upload Batch Worker Function: Upload Config Set for Translation
1 string reference to 'lingotek_sync_upload_config_set'
- lingotek_get_sync_upload_config_batch_elements in ./
lingotek.batch.inc - Sync - Upload Config Batch Elements: Creates the batch elements for config (ie. menus, taxonomies, etc.), that need to be uploaded.
File
- ./
lingotek.batch.inc, line 299 - Central location for batch create functions, before control is handed off to individual batch command files.
Code
function lingotek_sync_upload_config_set($set_id, &$context) {
if ($context) {
$context['message'] = t('Uploading configuration set #@sid for translation', array(
'@sid' => $set_id,
));
}
$api = LingotekApi::instance();
$set = LingotekConfigSet::loadById($set_id);
module_invoke_all('lingotek_pre_upload', $set);
if ($existing_document = $set
->hasLingotekDocId()) {
LingotekLog::trace('existing document: @existing', array(
'@existing' => $existing_document,
));
$result = $api
->updateContentDocument($set);
}
else {
$result = $api
->addContentDocument($set, TRUE);
}
if ($result) {
$context['results']['uploads'] = isset($context['results']['uploads']) && is_numeric($context['results']['uploads']) ? $context['results']['uploads'] + 1 : 1;
if (!isset($context['results']['uploaded_cids']) || !is_array($context['results']['uploaded_cids'])) {
$context['results']['uploaded_cids'] = array();
}
$context['results']['uploaded_cids'][] = $set_id;
}
else {
$context['results']['upload_fails'] = isset($context['results']['upload_fails']) && is_numeric($context['results']['upload_fails']) ? $context['results']['upload_fails'] + 1 : 1;
if (!isset($context['results']['upload_fail_cids']) || !is_array($context['results']['upload_fail_cids'])) {
$context['results']['upload_fail_cids'] = array();
}
$context['results']['upload_fail_cids'][] = $set_id;
}
}