function ctools_context_select

Choose a context or contexts based upon the selection made via ctools_context_filter.

Parameters

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

array|ctools_context_required $required: The required context object(s) provided by the plugin.

$context: The selection made using ctools_context_selector().

Return value

ctools_context|array|false Returns FALSE if $required is not an object, or array of objects, or the value of $required->select() for the context, or an array of those (if passed an array in $required).

4 calls to ctools_context_select()
ctools_access in includes/context.inc
Determine if the current user has access via a plugin.
ctools_access_add_restrictions in includes/context.inc
Apply restrictions to contexts based upon the access control configured.
ctools_access_summary in includes/context.inc
Get a summary of an access plugin's settings.
ctools_content_select_context in includes/content.inc
Select the context to be used for a piece of content, based upon config.

File

includes/context.inc, line 911

Code

function ctools_context_select($contexts, $required, $context) {
    if (is_array($required)) {
        
        /**
         * @var array $required
         *   Array of required context objects.
         * @var ctools_context_required $item
         *   A required context object.
         */
        $result = array();
        foreach ($required as $id => $item) {
            // @todo What's the difference between the following and "empty($item)" ?
            if (empty($required[$id])) {
                continue;
            }
            if (($result[] = _ctools_context_select($contexts, $item, $context[$id])) === FALSE) {
                return FALSE;
            }
        }
        return $result;
    }
    return _ctools_context_select($contexts, $required, $context);
}