function ctools_context_filter in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 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
$contexts: A keyed array of all available contexts.
$required: A ctools_context_required or ctools_context_optional object, or an array of such objects.
Return value
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 - _ctools_context_selector in includes/
context.inc
File
- includes/
context.inc, line 242 - 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 $r) {
$result = array_merge($result, _ctools_context_filter($contexts, $r));
}
return $result;
}
return _ctools_context_filter($contexts, $required);
}