public function AcquiaLiftAgent::getDecisionSyncOperations in Acquia Lift Connector 7
Returns the operations needed to sync decisions to Acquia Lift.
Parameters
$old_decisions: An array representing the old decisions Acquia Lift knows about.
$new_decisions: An array representing the new decisions.
Return value
array An array of items representing API calls to be made to Acquia Lift.
1 call to AcquiaLiftAgent::getDecisionSyncOperations()
- AcquiaLiftAgent::syncDecisions in plugins/
agent_types/ AcquiaLiftAgent.inc - Implements AcquiaLiftAgentInterface::syncDecisions().
File
- plugins/
agent_types/ AcquiaLiftAgent.inc, line 903 - Provides an agent type for Acquia Lift
Class
Code
public function getDecisionSyncOperations($old_decisions, $new_decisions) {
$items = array();
// Save everything in $new_decisions to Acquia Lift.
foreach ($new_decisions as $point => $decisions) {
$items[] = array(
'method' => 'savePoint',
'args' => array(
$this->machineName,
$point,
),
);
foreach ($decisions as $decision_name => $choices) {
$items[] = array(
'method' => 'saveDecision',
'args' => array(
$this->machineName,
$point,
$decision_name,
),
);
foreach ($choices as $choice) {
$items[] = array(
'method' => 'saveChoice',
'args' => array(
$this->machineName,
$point,
$decision_name,
$choice,
),
);
}
}
}
// Now remove anything that was in $old_decisions but not in
// $new_decisions.
foreach ($old_decisions as $point => $decisions) {
if (!isset($new_decisions[$point])) {
$items[] = array(
'method' => 'deletePoint',
'args' => array(
$this->machineName,
$point,
),
);
}
else {
foreach ($decisions as $decision_name => $choices) {
if (!isset($new_decisions[$point][$decision_name])) {
// Delete this decision from the decision point.
$items[] = array(
'method' => 'deleteDecision',
'args' => array(
$this->machineName,
$point,
$decision_name,
),
);
}
else {
foreach ($choices as $choice) {
if (!in_array($choice, $new_decisions[$point][$decision_name])) {
// Delete this choice from the decision.
$items[] = array(
'method' => 'deleteChoice',
'args' => array(
$this->machineName,
$point,
$decision_name,
$choice,
),
);
}
}
}
}
}
}
return $items;
}