You are here

function ctools_context_filter in Chaos Tool Suite (ctools) 7

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

Return a keyed array of context that match the given 'required context' filters.

Functions or systems that require contexts of a particular type provide a ctools_context_required or ctools_context_optional object. This function examines that object and an array of contexts to determine which contexts match the filter.

Since multiple contexts can be required, this function will accept either an array of all required contexts, or just a single required context object.

Parameters

array $contexts: A keyed array of all available contexts.

array|ctools_context_required|ctools_context_optional $required: A *_required or *_optional object, or an array of such objects, which define the selection condition.

Return value

array A keyed array of contexts that match the filter.

5 calls to ctools_context_filter()
ctools_content_select_context in includes/content.inc
Select the context to be used for a piece of content, based upon config.
ctools_context_get_relevant_relationships in includes/context.inc
Fetch all relevant relationships.
ctools_context_match_requirements in includes/context.inc
Are there enough contexts for a plugin?
_ctools_context_converter_selector in includes/context.inc
Helper function for ctools_context_converter_selector().
_ctools_context_selector in includes/context.inc
Helper function for ctools_context_selector().

File

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

Code

function ctools_context_filter($contexts, $required) {
  if (is_array($required)) {
    $result = array();
    foreach ($required as $item) {
      $result = array_merge($result, _ctools_context_filter($contexts, $item));
    }
    return $result;
  }
  return _ctools_context_filter($contexts, $required);
}