function acquia_lift_save_targeting_structure in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 acquia_lift.admin.inc \acquia_lift_save_targeting_structure()
Saves the targeting structure defined via the UI.
This does not actually *create* the structure defined via the UI as that happens once the final review stage has been completed.
Parameters
$agent: A stdClass ogject representing the agent to save the targeting structure for.
$targeting: An array keyed by target audience with arrays of option IDs as values.
Throws
3 calls to acquia_lift_save_targeting_structure()
- AcquiaLiftWebTestTarget::testAssignVariations in tests/
acquia_lift.test - AcquiaLiftWebTestTarget::testImplementTargetingStructure in tests/
acquia_lift.test - acquia_lift_targeting_form_submit in ./
acquia_lift.admin.inc - Submit callback for the targeting form.
File
- ./
acquia_lift.admin.inc, line 1705 - acquia_lift.admin.inc Provides functions needed for the admin UI.
Code
function acquia_lift_save_targeting_structure($agent, $targeting) {
if ($agent->plugin != 'acquia_lift_target') {
throw new AcquiaLiftException('Invalid agent');
}
$option_set = acquia_lift_get_option_set_for_targeting($agent->machine_name);
// Check that the targeting rules for the specified audiences exist in the
// option set.
foreach ($targeting as $audience => $vars) {
if (!isset($option_set->targeting[$audience])) {
throw new AcquiaLiftException('Invalid audience');
}
}
$agent->data['lift_targeting'] = $targeting;
personalize_agent_save($agent);
}