function lingotek_batch_update_entity_languages_by_profile in Lingotek Translation 7.7
1 call to lingotek_batch_update_entity_languages_by_profile()
- lingotek_admin_profiles_form in ./lingotek.admin.inc
File
- ./lingotek.batch.inc, line 804
- Central location for batch create functions, before control is handed off to individual batch command files.
Code
function lingotek_batch_update_entity_languages_by_profile($profile_id) {
if ($profile_id == LingotekSync::PROFILE_DISABLED) {
return;
}
$profile = LingotekProfile::loadById($profile_id);
$available_locales = lingotek_get_target_locales();
$target_locales_hash = $profile
->filterTargetLocales($available_locales);
$target_locales = array_keys($target_locales_hash);
$entities = $profile
->getEntities();
$operations = array();
foreach ($entities as $e) {
if (!empty($e['document_id'])) {
$entity_locales = lingotek_get_current_locales($e['type'], $e['id']);
$locales_to_add = array_diff($target_locales, $entity_locales);
$operations[] = array(
'lingotek_add_target_locales',
array(
$e,
$locales_to_add,
$profile,
),
);
$locales_to_remove = array_diff($entity_locales, $target_locales);
$operations[] = array(
'lingotek_remove_target_locales',
array(
$e,
$locales_to_remove,
),
);
}
}
if (!empty($operations)) {
$batch = array(
'title' => t('Updating target locales for entities in profile @profile_name', array(
'@profile_name' => $profile
->getName(),
)),
'operations' => $operations,
'finished' => 'lingotek_batch_update_entity_languages_by_profile_finished',
'file' => 'lingotek.batch.inc',
);
batch_set($batch);
batch_process('admin/settings/lingotek/settings');
}
}