function ctools_context_get_relevant_relationships

Fetch all relevant relationships.

Relevant relationships are any relationship that can be created based upon the list of existing contexts. For example, the 'node author' relationship is relevant if there is a 'node' context, but makes no sense if there is not one.

Parameters

$contexts: An array of contexts used to figure out which relationships are relevant.

Return value

array An array of relationship keys that are relevant for the given set of contexts.

See also

ctools_context_filter()

ctools_context_get_context_from_relationship()

ctools_context_get_context_from_relationships()

2 calls to ctools_context_get_relevant_relationships()
ctools_context_add_relationship_form in includes/context-admin.inc
ctools_context_ajax_item_add in includes/context-admin.inc
Ajax entry point to add an context

File

includes/context.inc, line 1386

Code

function ctools_context_get_relevant_relationships($contexts) {
    $relevant = array();
    $relationships = ctools_get_relationships();
    // Go through each relationship.
    foreach ($relationships as $rid => $relationship) {
        // For each relationship, see if there is a context that satisfies it.
        if (empty($relationship['no ui']) && ctools_context_filter($contexts, $relationship['required context'])) {
            $relevant[$rid] = $relationship['title'];
        }
    }
    return $relevant;
}