You are here

public function AcquiaLiftAgent::getGoalSyncOperations in Acquia Lift Connector 7

Returns the operations needed to sync goals to Acquia Lift.

Parameters

$old_goals: An array representing the old goals Acquia Lift knows about.

$new_goals: An array representing the new goals.

Return value

array An array of items representing API calls to be made to Acquia Lift.

1 call to AcquiaLiftAgent::getGoalSyncOperations()
AcquiaLiftAgent::syncGoals in plugins/agent_types/AcquiaLiftAgent.inc
Implements AcquiaLiftAgentInterface::syncGoals().

File

plugins/agent_types/AcquiaLiftAgent.inc, line 1001
Provides an agent type for Acquia Lift

Class

AcquiaLiftAgent

Code

public function getGoalSyncOperations($old_goals, $new_goals) {
  $items = array();

  // Save the new goals to Acquia Lift
  foreach ($new_goals as $goal_name => $goal_value) {
    $items[] = array(
      'method' => 'saveGoal',
      'args' => array(
        $this->machineName,
        $goal_name,
      ),
    );
  }

  // Now delete any old goals that are not in the new goals array.
  foreach ($old_goals as $goal_name => $goal_value) {
    if (!isset($new_goals[$goal_name])) {
      $items[] = array(
        'method' => 'deleteGoal',
        'args' => array(
          $this->machineName,
          $goal_name,
        ),
      );
    }
  }
  return $items;
}