1 views_handler_filter_in_operator.inc views_handler_filter_in_operator::reduce_value_options($input = NULL)

When using exposed filters, we may be required to reduce the set.

File

core/modules/views/handlers/views_handler_filter_in_operator.inc, line 245
Definition of views_handler_filter_in_operator.

Class

views_handler_filter_in_operator
Simple filter to handle matching of multiple options selectable via checkboxes

Code

function reduce_value_options($input = NULL) {
  if (!isset($input)) {
    $input = $this->value_options;
  }

  // Because options may be an array of strings, or an array of mixed arrays
  // and strings (optgroups) or an array of objects, we have to
  // step through and handle each one individually.
  $options = array();
  foreach ($input as $id => $option) {
    if (is_array($option)) {
      $options[$id] = $this->reduce_value_options($option);
      continue;
    }
    elseif (is_object($option)) {
      $keys = array_keys($option->option);
      $key = array_shift($keys);
      if (isset($this->options['value'][$key])) {
        $options[$id] = $option;
      }
    }
    elseif (isset($this->options['value'][$id])) {
      $options[$id] = $option;
    }
  }
  return $options;
}