You are here

function ctools_context_get_context_from_relationships in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/context.inc \ctools_context_get_context_from_relationships()

Fetch all active relationships.

Parameters

$relationships: An keyed array of relationship data including:

  • name: name of relationship
  • context: context id relationship belongs to. This will be used to identify which context in the $contexts array to use to create the relationship context.

$contexts: A keyed array of contexts used to figure out which relationships are relevant. New contexts will be added to this.

$placeholders: If TRUE, placeholders are acceptable.

See also

ctools_context_get_context_from_relationship()

ctools_context_get_relevant_relationships()

1 call to ctools_context_get_context_from_relationships()
ctools_context_load_contexts in includes/context.inc
Load a full array of contexts for an object.

File

includes/context.inc, line 1410
Contains code related to the ctools system of 'context'.

Code

function ctools_context_get_context_from_relationships($relationships, &$contexts, $placeholders = FALSE) {
  foreach ($relationships as $rdata) {
    if (!isset($rdata['context'])) {
      continue;
    }
    if (is_array($rdata['context'])) {
      $rcontexts = array();
      foreach ($rdata['context'] as $cid) {
        if (!empty($contexts[$cid])) {
          $rcontexts[] = $contexts[$cid];
        }
      }
    }
    elseif (!empty($contexts[$rdata['context']])) {
      $rcontexts = $contexts[$rdata['context']];
    }
    $cid = ctools_context_id($rdata, 'relationship');
    if ($context = ctools_context_get_context_from_relationship($rdata, $rcontexts)) {
      $contexts[$cid] = $context;
    }
  }
}