You are here

function ctools_context_match_required_contexts in Chaos Tool Suite (ctools) 7

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

Match up external contexts to our required contexts.

This function is used to create a list of contexts with proper IDs based upon a list of required contexts.

These contexts passed in should match the numeric positions of the required contexts. The caller must ensure this has already happened correctly as this function will not detect errors here.

Parameters

$required: A list of required contexts as defined by the UI.

$contexts: A list of matching contexts as passed in from the calling system.

Return value

array Array of contexts, keyed by context ID.

1 call to ctools_context_match_required_contexts()
ctools_ruleset_ctools_access_check in ctools_access_ruleset/plugins/access/ruleset.inc
Check for access.

File

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

Code

function ctools_context_match_required_contexts($required, $contexts) {
  $return = array();
  if (!is_array($required)) {
    return $return;
  }
  foreach ($required as $r) {
    $context = clone array_shift($contexts);
    $context->identifier = $r['identifier'];
    $context->page_title = isset($r['title']) ? $r['title'] : '';
    $context->keyword = $r['keyword'];
    $return[ctools_context_id($r, 'requiredcontext')] = $context;
  }
  return $return;
}