1 views_handler_filter.inc views_handler_filter::init(&$view, &$options)

Provide some extra help to get the operator/value easier to use.

This likely has to be overridden by filters which are more complex than simple operator/value.

Overrides views_handler::init

File

core/modules/views/handlers/views_handler_filter.inc, line 74
@todo.

Class

views_handler_filter
Base class for filters.

Code

function init(&$view, &$options) {
  parent::init($view, $options);

  $this->operator = $this->options['operator'];
  $this->value = $this->options['value'];
  $this->group_info = $this->options['group_info']['default_group'];

  // Compatibility: The new UI changed several settings.
  if (!empty($options['exposed']) && !empty($options['expose']['optional']) && !isset($options['expose']['required'])) {
    $this->options['expose']['required'] = !$options['expose']['optional'];
  }
  if (!empty($options['exposed']) && !empty($options['expose']['single']) && !isset($options['expose']['multiple'])) {
    $this->options['expose']['multiple'] = !$options['expose']['single'];
  }
  if (!empty($options['exposed']) && !empty($options['expose']['operator']) && !isset($options['expose']['operator_id'])) {
    $this->options['expose']['operator_id'] = $options['expose']['operator_id'] = $options['expose']['operator'];
  }

  if ($this->multiple_exposed_input()) {
    $this->group_info = array_filter($options['group_info']['default_group_multiple']);
    $this->options['expose']['multiple'] = TRUE;
  }

  // If there are relationships in the view, allow empty should be true
  // so that we can do IS NULL checks on items. Not all filters respect
  // allow empty, but string and numeric do and that covers enough.
  if ($this->view->display_handler->get_option('relationships')) {
    $this->definition['allow empty'] = TRUE;
  }
}