function InOperator::reduce_value_options

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

2 calls to InOperator::reduce_value_options()
InOperator::value_form in drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/InOperator.php
Options form subform for setting options.
TaxonomyIndexTid::value_form in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/filter/TaxonomyIndexTid.php
Options form subform for setting options.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/InOperator.php, line 251
Definition of Drupal\views\Plugin\views\filter\InOperator.

Class

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

Namespace

Drupal\views\Plugin\views\filter

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;
}