You are here

function _acquia_lift_get_mapped_context in Acquia Lift Connector 7.3

Gets the mapped context for the current node including field mappings and udf mappings.

Parameters

$node: The node currently be displayed

Return value

array An array of contexts to be included with the page context.

1 call to _acquia_lift_get_mapped_context()
_acquia_lift_get_page_context in ./acquia_lift.context.inc
Handles the page context request data.

File

./acquia_lift.context.inc, line 106
acquia_lift.context.inc Provides functions needed for handling visitor contexts.

Code

function _acquia_lift_get_mapped_context($node) {
  $mapped_context = array();
  $mapping_callbacks = _acquia_lift_get_mapping_callbacks();

  // Field Mappings include content section, keywords, persona, etc.
  $field_mappings = variable_get('acquia_lift_field_mappings', array());
  foreach ($field_mappings as $type => $mapping) {
    list($context_type, $context) = explode(ACQUIA_LIFT_ADMIN_SEPARATOR, $mapping);
    if (!array_key_exists($context_type, $mapping_callbacks)) {
      continue;
    }
    $mapped_value = call_user_func($mapping_callbacks[$context_type], $node, $context);
    if (!is_null($mapped_value)) {
      $mapped_context[$type] = $mapped_value;
    }
  }

  // UDF Mappings include keys for person, touch, event, etc.
  $udf_mappings = variable_get('acquia_lift_udf_mappings', array());
  foreach ($udf_mappings as $type => $mapping) {
    foreach ($mapping as $udf => $mapping_context) {
      list($context_type, $context) = explode(ACQUIA_LIFT_ADMIN_SEPARATOR, $mapping_context);
      if (!array_key_exists($context_type, $mapping_callbacks)) {
        continue;
      }
      $mapped_value = call_user_func($mapping_callbacks[$context_type], $node, $context);
      if (!is_null($mapped_value)) {
        $mapped_context[$udf] = $mapped_value;
      }
    }
  }
  return $mapped_context;
}