Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from wearewondrous/D9-Compatibility
Browse files Browse the repository at this point in the history
D9 compatibility
  • Loading branch information
bia-wtag authored Aug 10, 2021
2 parents e36b750 + 40f5669 commit a204e7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 11 additions & 11 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 @@ -367,17 +367,17 @@ protected function getOids() {
$display = $view_copy->getDisplay();

// Remove any exposed form configuration. This showed up with BEF module!
unset($display->display_options['exposed_form']);
unset($display->display['display_options']['exposed_form']);

$fields =& $display->getHandlers('field');
$fields = array_intersect_key($fields, [$this->options['selective_display_field'] => TRUE]);

// 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

0 comments on commit a204e7a

Please sign in to comment.