function acquia_lift_profiles_batch_sync_action in Acquia Lift Connector 7.2
Same name and namespace in other branches
- 7 acquia_lift_profiles/acquia_lift_profiles.batch.inc \acquia_lift_profiles_batch_sync_action()
Batch API callback to sync an action to Lift web
Parameters
$item: An array representing the action to sync with keys 'label' and 'action_name'.
&$context: Parameter passed in by Batch API to allow keeping track of operation progress.
1 string reference to 'acquia_lift_profiles_batch_sync_action'
- acquia_lift_batch_sync_actions in acquia_lift_profiles/
acquia_lift_profiles.batch.inc - Batch syncs actions to Lift Web.
File
- acquia_lift_profiles/
acquia_lift_profiles.batch.inc, line 50 - acquia_lift_profiles.batch.inc Provides Acquia Lift Profiles batch functions.
Code
function acquia_lift_profiles_batch_sync_action($item, &$context) {
if (!isset($context['sandbox']['progress'])) {
$context['sandbox']['progress'] = 0;
}
if (!isset($context['sandbox']['retries'])) {
$context['sandbox']['retries'] = 0;
}
$errors = array();
acquia_lift_profiles_put_action($item['action_name'], $item['label'], $errors);
if (empty($errors)) {
$context['results'][] = t('Action @action synchronized successfully', array(
'@action' => $item['label'],
));
$context['sandbox']['progress']++;
}
else {
// We allow one retry per operation.
if (!$context['sandbox']['retries']) {
$context['finished'] = 0.5;
$context['sandbox']['retries'] = 1;
}
else {
// Is there a better way to signal that a particular operation was
// unsuccessful during batch processing?
$context['results'][] = ACQUIA_LIFT_OPERATION_ERROR_PREFIX . implode(',', $errors);
$context['sandbox']['progress']++;
// Reset retries for the next operation.
$context['sandbox']['retries'] = 0;
}
}
}