You are here

function acquia_lift_delete_old_nested_test in Acquia Lift Connector 7

Deletes a nested test that is no longer needed.

Parameters

$parent_agent: The name of the parent agent.

$audience: THe name of the target audience the test was assigned to.

Throws

\PersonalizeException

1 call to acquia_lift_delete_old_nested_test()
acquia_lift_update_targeting in ./acquia_lift.admin.inc
Takes whatever is in the 'lift_targeting' data property and converts it into the required campaign structure (including nested tests where needed).

File

./acquia_lift.admin.inc, line 1679
acquia_lift.admin.inc Provides functions needed for the admin UI.

Code

function acquia_lift_delete_old_nested_test($parent_agent, $audience) {
  $option_set = acquia_lift_get_option_set_for_targeting($parent_agent->machine_name);

  // Find the nested option set for the specified targeting rule.
  if (isset($option_set->targeting[$audience]) && isset($option_set->targeting[$audience]['osid'])) {
    $nested_os = personalize_option_set_load($option_set->targeting[$audience]['osid']);

    // Delete the option set, then delete the agent.
    personalize_option_set_delete($option_set->targeting[$audience]['osid']);
    personalize_agent_delete($nested_os->agent);
    unset($option_set->targeting[$audience]['osid']);
  }
  personalize_option_set_save($option_set);
}