You are here

public function FilterPluginBase::init in Views (for Drupal 7) 8.3

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 HandlerBase::init

2 calls to FilterPluginBase::init()
BooleanOperator::init in lib/Drupal/views/Plugin/views/filter/BooleanOperator.php
Overrides Drupal\views\Plugin\views\filter\FilterPluginBase::init().
InOperator::init in lib/Drupal/views/Plugin/views/filter/InOperator.php
Overrides Drupal\views\Plugin\views\filter\FilterPluginBase::init().
3 methods override FilterPluginBase::init()
BooleanOperator::init in lib/Drupal/views/Plugin/views/filter/BooleanOperator.php
Overrides Drupal\views\Plugin\views\filter\FilterPluginBase::init().
Broken::init in lib/Drupal/views/Plugin/views/filter/Broken.php
Provide some extra help to get the operator/value easier to use.
InOperator::init in lib/Drupal/views/Plugin/views/filter/InOperator.php
Overrides Drupal\views\Plugin\views\filter\FilterPluginBase::init().

File

lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php, line 82
Definition of Drupal\views\Plugin\views\filter\FilterPluginBase.

Class

FilterPluginBase
Base class for filters.

Namespace

Drupal\views\Plugin\views\filter

Code

public function init(ViewExecutable $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'];

  // Set the default value of the operator ID.
  if (!empty($options['exposed']) && !empty($options['expose']['operator']) && !isset($options['expose']['operator_id'])) {
    $this->options['expose']['operator_id'] = $options['expose']['operator'];
  }
  if ($this
    ->multipleExposedInput()) {
    $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
    ->getOption('relationships')) {
    $this->definition['allow empty'] = TRUE;
  }
}