You are here

function acquia_lift_personalize_agent_presave in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 acquia_lift.module \acquia_lift_personalize_agent_presave()

Implements hook_personalize_agent_presave().

File

./acquia_lift.module, line 561
acquia_lift.module Provides Acquia Lift-specific personalization functionality.

Code

function acquia_lift_personalize_agent_presave($agent) {
  if (!in_array($agent->plugin, array(
    'acquia_lift',
    'acquia_lift_simple_ab',
  ))) {
    return;
  }
  $account = variable_get('acquia_lift_account_info', array());
  $current = personalize_agent_load($agent->machine_name);
  if (empty($current)) {
    $agent->machine_name = AcquiaLiftAPI::getInstance($account)
      ->ensureUniqueAgentName($agent->machine_name, PERSONALIZE_MACHINE_NAME_MAXLENGTH);
  }

  // Make sure the required configurations are set.
  if (!isset($agent->data['decision_style'])) {
    $agent->data['decision_style'] = 'adaptive';
  }
  if (!isset($agent->data['control_rate'])) {
    $agent->data['control_rate'] = 10;
  }
  if (!isset($agent->data['explore_rate'])) {
    $agent->data['explore_rate'] = 20;
  }
}