3 namespace Drupal\views_test_data\Plugin\views\display_extender;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase;
9 * Defines a display extender test plugin.
11 * @ViewsDisplayExtender(
12 * id = "display_extender_test",
13 * title = @Translation("Display extender test")
16 class DisplayExtenderTest extends DisplayExtenderPluginBase {
19 * Stores some state booleans to be sure a certain method got called.
28 protected function defineOptions() {
29 $options = parent::defineOptions();
31 $options['test_extender_test_option'] = ['default' => $this->t('Empty')];
39 public function optionsSummary(&$categories, &$options) {
40 parent::optionsSummary($categories, $options);
42 $categories['display_extender_test'] = [
43 'title' => $this->t('Display extender test settings'),
50 $options['test_extender_test_option'] = [
51 'category' => 'display_extender_test',
52 'title' => $this->t('Test option'),
53 'value' => views_ui_truncate($this->options['test_extender_test_option'], 24),
60 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
61 switch ($form_state->get('section')) {
62 case 'test_extender_test_option':
63 $form['#title'] .= $this->t('Test option');
64 $form['test_extender_test_option'] = [
65 '#title' => $this->t('Test option'),
66 '#type' => 'textfield',
67 '#description' => $this->t('This is a textfield for test_option.'),
68 '#default_value' => $this->options['test_extender_test_option'],
76 public function submitOptionsForm(&$form, FormStateInterface $form_state) {
77 parent::submitOptionsForm($form, $form_state);
78 switch ($form_state->get('section')) {
79 case 'test_extender_test_option':
80 $this->options['test_extender_test_option'] = $form_state->getValue('test_extender_test_option');
88 public function defaultableSections(&$sections, $section = NULL) {
89 $sections['test_extender_test_option'] = ['test_extender_test_option'];
95 public function query() {
96 $this->testState['query'] = TRUE;
102 public function preExecute() {
103 $this->testState['preExecute'] = TRUE;