You are here

function acquia_lift_batch_sync_tests_for_agent in Acquia Lift Connector 7.2

Batch syncs the nested tests for the specified agent.

Parameters

stdClass $agent:

Return value

bool Returns TRUE if batch syncing completed successfully, FALSE otherwise.

1 call to acquia_lift_batch_sync_tests_for_agent()
acquia_lift_target_set_status in ./acquia_lift.admin.inc
Update the status of an acquia lift target agent and synchronize any necessary configuration to Lift.

File

./acquia_lift.batch.inc, line 16
acquia_lift.batch.inc

Code

function acquia_lift_batch_sync_tests_for_agent($agent, $status_change = NULL) {
  try {
    $operations = acquia_lift_get_sync_operations_for_agent($agent);

    // We don't get to pass additional info to the callback, such as what we'd
    // like it to do upon success, so we define a different callback depending
    // on what has been passed as the $status_change parameter.
    $finish_callback = 'acquia_lift_batch_finished';
    if ($status_change == PERSONALIZE_STATUS_RUNNING) {
      $finish_callback = 'acquia_lift_batch_finish_and_start_campaign';
    }
    elseif ($status_change == PERSONALIZE_STATUS_SCHEDULED) {
      $finish_callback = 'acquia_lift_batch_finish_and_schedule_campaign';
    }
    $_SESSION['acquia_lift_agent_sync'] = $agent->machine_name;
    acquia_lift_do_batch_sync($operations, $finish_callback);
  } catch (AcquiaLiftException $e) {
    drupal_set_message(t('There was a problem syncing your personalization components to Lift: %error. Please !review your personalization and correct any problems listed.', array(
      '%error' => $e
        ->getMessage(),
      '!review' => l('review', 'admin/structure/personalize/manage/' . $agent->machine_name . '/review'),
    )), 'error');
  }
}