FilterTest.php

Same filename in this branch
  1. 11.x core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php
  2. 11.x core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php
  3. 11.x core/modules/views/tests/src/Functional/Plugin/FilterTest.php
Same filename and directory in other branches
  1. 9 core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php
  2. 9 core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php
  3. 9 core/modules/views/tests/src/Functional/Plugin/FilterTest.php
  4. 9 core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php
  5. 8.9.x core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php
  6. 8.9.x core/modules/views/tests/src/Functional/Plugin/FilterTest.php
  7. 8.9.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php
  8. 10 core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php
  9. 10 core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php
  10. 10 core/modules/views/tests/src/Functional/Plugin/FilterTest.php
  11. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php

Namespace

Drupal\views_test_data\Plugin\views\filter

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php

View source
<?php

namespace Drupal\views_test_data\Plugin\views\filter;

use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Attribute\ViewsFilter;
use Drupal\views\Plugin\views\filter\FilterPluginBase;
class FilterTest extends FilterPluginBase {
    
    /**
     * Overrides Drupal\views\Plugin\views\row\RowPluginBase::defineOptions().
     *
     * @return array
     */
    protected function defineOptions() {
        $options = parent::defineOptions();
        $options['test_enable'] = [
            'default' => TRUE,
        ];
        return $options;
    }
    
    /**
     * {@inheritdoc}
     */
    public function buildOptionsForm(&$form, FormStateInterface $form_state) {
        parent::buildOptionsForm($form, $form_state);
        $form['test_enable'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Controls whether the filter plugin should be active'),
            '#default_value' => $this->options['test_enable'],
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function query() {
        // Call the parent if this option is enabled.
        if ($this->options['test_enable']) {
            parent::query();
        }
    }

}

Classes

Title Deprecated Summary
FilterTest

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