You are here

protected function FilterPluginBase::defineOptions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::defineOptions()
  2. 10 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::defineOptions()

Information about options for all kinds of purposes will be held here.


'option_name' => array(
 - 'default' => default value,
 - 'contains' => (optional) array of items this contains, with its own
     defaults, etc. If contains is set, the default will be ignored and
     assumed to be array().
 ),

Return value

array Returns the options of this handler/plugin.

Overrides HandlerBase::defineOptions

6 calls to FilterPluginBase::defineOptions()
BooleanOperator::defineOptions in core/modules/views/src/Plugin/views/filter/BooleanOperator.php
Information about options for all kinds of purposes will be held here.
FilterTest::defineOptions in core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php
Overrides Drupal\views\Plugin\views\row\RowPluginBase::defineOptions().
InOperator::defineOptions in core/modules/views/src/Plugin/views/filter/InOperator.php
Information about options for all kinds of purposes will be held here.
NumericFilter::defineOptions in core/modules/views/src/Plugin/views/filter/NumericFilter.php
Information about options for all kinds of purposes will be held here.
Search::defineOptions in core/modules/search/src/Plugin/views/filter/Search.php
Information about options for all kinds of purposes will be held here.

... See full list

6 methods override FilterPluginBase::defineOptions()
BooleanOperator::defineOptions in core/modules/views/src/Plugin/views/filter/BooleanOperator.php
Information about options for all kinds of purposes will be held here.
FilterTest::defineOptions in core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php
Overrides Drupal\views\Plugin\views\row\RowPluginBase::defineOptions().
InOperator::defineOptions in core/modules/views/src/Plugin/views/filter/InOperator.php
Information about options for all kinds of purposes will be held here.
NumericFilter::defineOptions in core/modules/views/src/Plugin/views/filter/NumericFilter.php
Information about options for all kinds of purposes will be held here.
Search::defineOptions in core/modules/search/src/Plugin/views/filter/Search.php
Information about options for all kinds of purposes will be held here.

... See full list

File

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

Class

FilterPluginBase
Base class for Views filters handler plugins.

Namespace

Drupal\views\Plugin\views\filter

Code

protected function defineOptions() {
  $options = parent::defineOptions();
  $options['operator'] = [
    'default' => '=',
  ];
  $options['value'] = [
    'default' => '',
  ];
  $options['group'] = [
    'default' => '1',
  ];
  $options['exposed'] = [
    'default' => FALSE,
  ];
  $options['expose'] = [
    'contains' => [
      'operator_id' => [
        'default' => FALSE,
      ],
      'label' => [
        'default' => '',
      ],
      'description' => [
        'default' => '',
      ],
      'use_operator' => [
        'default' => FALSE,
      ],
      'operator' => [
        'default' => '',
      ],
      'operator_limit_selection' => [
        'default' => FALSE,
      ],
      'operator_list' => [
        'default' => [],
      ],
      'identifier' => [
        'default' => '',
      ],
      'required' => [
        'default' => FALSE,
      ],
      'remember' => [
        'default' => FALSE,
      ],
      'multiple' => [
        'default' => FALSE,
      ],
      'remember_roles' => [
        'default' => [
          RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID,
        ],
      ],
    ],
  ];

  // A group is a combination of a filter, an operator and a value
  // operating like a single filter.
  // Users can choose from a select box which group they want to apply.
  // Views will filter the view according to the defined values.
  // Because it acts as a standard filter, we have to define
  // an identifier and other settings like the widget and the label.
  // This settings are saved in another array to allow users to switch
  // between a normal filter and a group of filters with a single click.
  $options['is_grouped'] = [
    'default' => FALSE,
  ];
  $options['group_info'] = [
    'contains' => [
      'label' => [
        'default' => '',
      ],
      'description' => [
        'default' => '',
      ],
      'identifier' => [
        'default' => '',
      ],
      'optional' => [
        'default' => TRUE,
      ],
      'widget' => [
        'default' => 'select',
      ],
      'multiple' => [
        'default' => FALSE,
      ],
      'remember' => [
        'default' => 0,
      ],
      'default_group' => [
        'default' => 'All',
      ],
      'default_group_multiple' => [
        'default' => [],
      ],
      'group_items' => [
        'default' => [],
      ],
    ],
  ];
  return $options;
}