You are here

public static function AcquiaLiftAPI::mapStatus in Acquia Lift Connector 7

Maps the passed in status code to one consumable by the Lift service.

If the passed in status code is already a string status code that's consumable by Lift it just returns that code. If it's a numeric code defined in personalize module it maps it to the corresponding string code. If it's neither, an exception is thrown.

Parameters

$status: The status to map.

Return value

string status The status code consumable by Lift.

Throws

AcquiaLiftException

2 calls to AcquiaLiftAPI::mapStatus()
AcquiaLiftAPI::saveAgent in includes/acquia_lift.classes.inc
Saves an agent to Acquia Lift.
AcquiaLiftAPI::updateAgentStatus in includes/acquia_lift.classes.inc
Updates the status of an agent in Acquia Lift.

File

includes/acquia_lift.classes.inc, line 157
Provides an agent type for Acquia Lift

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

public static function mapStatus($status) {
  $status_map = array(
    PERSONALIZE_STATUS_NOT_STARTED => self::PAUSED_STATUS,
    PERSONALIZE_STATUS_PAUSED => self::PAUSED_STATUS,
    PERSONALIZE_STATUS_RUNNING => self::ENABLED_STATUS,
    PERSONALIZE_STATUS_COMPLETED => self::STOPPED_STATUS,
  );

  // Maybe we already have a Lift status string.
  if (in_array($status, $status_map)) {
    return $status;
  }

  // Otherwise map it to a Lift status.
  if (!isset($status_map[$status])) {
    throw new AcquiaLiftException('Unknown agent status: ' . $status);
  }
  return $status_map[$status];
}