function acquia_lift_save_targeting_structure in Acquia Lift Connector 7.2
Same name and namespace in other branches
- 7 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 object representing the agent to save the targeting structure for.
$targeting: An array keyed by target audience with arrays of option IDs as values.
Throws
14 calls to acquia_lift_save_targeting_structure()
- AcquiaLiftWebTestAgentAdmin::testAgentList in tests/
acquia_lift.test - AcquiaLiftWebTestBase::createTargetingAgentWithNestedTest in tests/
acquia_lift.test - AcquiaLiftWebTestBase::createTestFromOptionSet in tests/
acquia_lift.test - AcquiaLiftWebTestFundamentals::createTestFromOptionSet in tests/
acquia_lift.test - AcquiaLiftWebTestReports::testAudienceReportLogic in tests/
acquia_lift.test
File
- ./
acquia_lift.admin.inc, line 1930 - 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);
}