You are here

function ctools_context_optional::select in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context.inc \ctools_context_optional::select()

Overrides ctools_context_required::select

File

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

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

function select($contexts, $context) {
  $this
    ->add_empty($contexts);
  if (empty($context)) {
    return $contexts['empty'];
  }
  $result = parent::select($contexts, $context);

  // Don't flip out if it can't find the context; this is optional, put
  // in an empty.
  if ($result == FALSE) {
    $result = $contexts['empty'];
  }
  return $result;
}