Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Plugin/views/filter/Selective.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Drupal\views_selective_filters\Plugin\views\filter;

use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
Expand Down Expand Up @@ -177,7 +177,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
'warning' => t('Warning message'),
],
)));
// Remove option to unexpose filter. Tried to disable, but did not work.
// Remove option to unexposed filter. Tried to disable, but did not work.
$form['expose_button']['checkbox']['checkbox']['#type'] = 'hidden';
// Do not allow to check "all values".
$form['value']['#access'] = FALSE;
Expand Down Expand Up @@ -226,7 +226,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['selective_display_sort'] = array(
'#title' => $this->t('Sort field'),
'#type' => 'select',
'#description' => $this->t('Choose wich field to use for display'),
'#description' => $this->t('Choose which field to use for display'),
'#options' => $options,
'#default_value' => $this->options['selective_display_sort'],
);
Expand Down Expand Up @@ -358,7 +358,7 @@ protected function getOids() {
// to return thousands of possible values.
$max_items = (int) $this->options['selective_items_limit'];

// Clone the view (so it works while editting) and get all results.
// Clone the view (so it works while editing) and get all results.
$view_copy = $this->getViewCopy();
if (!$view_copy) {
return NULL;
Expand All @@ -374,10 +374,10 @@ protected function getOids() {

// Check to see if the user remembered to add the field.
if (empty($fields)) {
drupal_set_message(t('Selective query filter must have corresponding field added to view with Administrative Name set to "@name" and Base Type "@type"',
\Drupal::messenger()->addMessage('Selective query filter must have corresponding field added to view with Administrative Name set to "@name" and Base Type "@type"',
array(
'@name' => $ui_name,
'@type' => $base_field)),
'@type' => $base_field),
'error');
return [];
}
Expand All @@ -399,10 +399,10 @@ protected function getOids() {
($field_options['relationship'] === $this->options['relationship']);

if (!$equal) {
drupal_set_message(t('Selective filter "@name": relationship of field and filter must match.',
\Drupal::messenger()->addMessage('Selective filter "@name": relationship of field and filter must match.',
array(
'@name' => $ui_name,
'@type' => $base_field)),
'@type' => $base_field),
'error');
return [];
}
Expand Down Expand Up @@ -469,7 +469,7 @@ protected function getOids() {
}

if (NULL !== $value) {
$oids[$key] = SafeMarkup::checkPlain($value);
$oids[$key] = Html::escape($value);
}
}
}
Expand Down Expand Up @@ -500,7 +500,7 @@ protected function getOids() {

// If limit exceeded this field is not good for being "selective".
if (!empty($max_items) && count($oids) === $max_items) {
drupal_set_message(t('Selective filter "@field" has limited the amount of total results. Please, review you query configuration.', array('@field' => $ui_name)), 'warning');
\Drupal::messenger()->addMessage('Selective filter "@field" has limited the amount of total results. Please, review you query configuration.', array('@field' => $ui_name), 'warning');
}

static::$results[$signature] = $oids;
Expand Down
1 change: 1 addition & 0 deletions views_selective_filters.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ type: module
description: Restrict exposed filter values to those present in the result set.
package: Views
core: 8.x
core_version_requirement: ^8 || ^9
dependencies:
- views