function ctools_context_optional::filter
Filter the contexts to determine which apply in the current environment.
As for ctools_context_required, but we add the empty context to those passed in so the check is optional (i.e. if nothing else matches, the empty context will, and so there will always be at least one matched).
Parameters
array $contexts: An array of ctools_context objects (or something which will cast to an array of them). The contexts to apply the filter on.
Return value
array An array of context objects, keyed with the same keys used for $contexts, which pass the filter.
Overrides ctools_context_required::filter
See also
File
-
includes/
context.inc, line 439
Class
- ctools_context_optional
- Used to compare to see if a list of contexts match an optional context. This can produce empty contexts to use as placeholders.
Code
public function filter($contexts) {
/**
* @todo We are assuming here that $contexts is actually an array, whereas
* ctools_context_required::filter only requires $contexts is convertible
* to an array.
*/
$this->add_empty($contexts);
return parent::filter($contexts);
}