3 namespace Drupal\d8views\Plugin\views\filter;
5 use Drupal\views\Plugin\views\display\DisplayPluginBase;
6 use Drupal\views\Plugin\views\filter\InOperator;
7 use Drupal\views\ViewExecutable;
10 * Filters by given list of node title options.
12 * @ingroup views_filter_handlers
14 * @ViewsFilter("d8views_node_titles")
16 class PermissionsByTerm extends InOperator {
21 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
22 parent::init($view, $display, $options);
23 $this->valueTitle = t('Allowed node titles');
24 $this->definition['options callback'] = [$this, 'generateOptions'];
30 * So that no filtering takes place if the user doesn't
33 public function query() {
34 if (!empty($this->value)) {
42 * If no options have been chosen so we can use it as a non-filter.
44 public function validate() {
45 if (!empty($this->value)) {
51 * Helper function that generates the options.
54 * Array keys are used to compare with the table field values.
56 public function generateOptions() {
58 'my title' => 'my title',
59 'another title' => 'another title',