function acquia_lift_page_variation_delete in Acquia Lift Connector 7
Delete a page variation.
Parameters
string $variation_set_name: The name of the variation set that contains the variation to be removed.
string $agent_name: The name of the campaign/agent for the page variation.
number $variation_number: The number for the variation to delete.
2 calls to acquia_lift_page_variation_delete()
- AcquiaLiftWebTestVariationSets::testVariationSets in tests/
acquia_lift.test - Tests variation set creation.
- acquia_lift_page_variation_delete_form_submit in ./
acquia_lift.admin.unibar.inc - Submit handler for acquia_lift_page_variation_delete_form().
File
- ./
acquia_lift.page_variations.inc, line 186 - acquia_lift.admin.page_variations.inc
Code
function acquia_lift_page_variation_delete($variation_set_name, $agent_name, $variation_number) {
$option_sets = personalize_option_set_load_multiple(FALSE, array(
'decision_name' => $variation_set_name,
'agent' => $agent_name,
));
foreach ($option_sets as $option_set) {
if (isset($option_set->options[$variation_number])) {
unset($option_set->options[$variation_number]);
personalize_option_set_save($option_set, FALSE);
}
}
// If the only variation left is the control variation, then delete
// all of the option sets for this variation.
if (count($option_set->options) === 1) {
$last_option = current($option_set->options);
if ($last_option['option_id'] === PERSONALIZE_CONTROL_OPTION_ID) {
reset($option_sets);
foreach ($option_sets as $option_set) {
personalize_option_set_delete($option_set->osid);
}
}
}
}