FilterTest.php in Zircon Profile 8
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\Plugin\views\filter\FilterPluginBase;
class FilterTest extends FilterPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
$options['test_enable'] = array(
'default' => TRUE,
);
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['test_enable'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Controls whether the filter plugin should be active'),
'#default_value' => $this->options['test_enable'],
);
}
public function query() {
if ($this->options['test_enable']) {
parent::query();
}
}
}
Classes
Name |
Description |
FilterTest |
Plugin annotation
@ViewsFilter("test_filter"); |