5bc7a190cd6e435a1ec3f6c90a5ea7bd6b8ee792
[yaffs-website] / web / core / modules / views / tests / modules / views_test_data / src / Plugin / views / filter / FilterTest.php
1 <?php
2
3 namespace Drupal\views_test_data\Plugin\views\filter;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\filter\FilterPluginBase;
7
8 /**
9  * @ViewsFilter("test_filter")
10  */
11 class FilterTest extends FilterPluginBase {
12
13   /**
14    * Overrides Drupal\views\Plugin\views\row\RowPluginBase::defineOptions().
15    *
16    * @return array
17    */
18   protected function defineOptions() {
19     $options = parent::defineOptions();
20
21     $options['test_enable'] = ['default' => TRUE];
22     return $options;
23   }
24
25   /**
26    * Overrides Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm().
27    *
28    * @return array
29    */
30   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
31     parent::buildOptionsForm($form, $form_state);
32
33     $form['test_enable'] = [
34       '#type' => 'checkbox',
35       '#title' => $this->t('Controls whether the filter plugin should be active'),
36       '#default_value' => $this->options['test_enable'],
37     ];
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   public function query() {
44     // Call the parent if this option is enabled.
45     if ($this->options['test_enable']) {
46       parent::query();
47     }
48   }
49
50 }