function FilterPluginBase::init

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::init()
  2. 8.9.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::init()
  3. 10 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::init()

Overrides \Drupal\views\Plugin\views\HandlerBase::init().

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

3 calls to FilterPluginBase::init()
BooleanOperator::init in core/modules/views/src/Plugin/views/filter/BooleanOperator.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().
InOperator::init in core/modules/views/src/Plugin/views/filter/InOperator.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().
Search::init in core/modules/search/src/Plugin/views/filter/Search.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().
4 methods override FilterPluginBase::init()
BooleanOperator::init in core/modules/views/src/Plugin/views/filter/BooleanOperator.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().
Broken::init in core/modules/views/src/Plugin/views/filter/Broken.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().
InOperator::init in core/modules/views/src/Plugin/views/filter/InOperator.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().
Search::init in core/modules/search/src/Plugin/views/filter/Search.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().

File

core/modules/views/src/Plugin/views/filter/FilterPluginBase.php, line 122

Class

FilterPluginBase
Base class for Views filters handler plugins.

Namespace

Drupal\views\Plugin\views\filter

Code

public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$options = NULL) {
    parent::init($view, $display, $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;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.