From 0a2f8c3e99a4910b2482e436854e1c35a5e56588 Mon Sep 17 00:00:00 2001 From: Amit Biswas Date: Fri, 6 Aug 2021 11:36:39 +0600 Subject: [PATCH 1/2] TSM-448: Maintenance: Updated codebase for D9 compatibility --- src/Plugin/views/filter/Selective.php | 20 ++++++++++---------- views_selective_filters.info.yml | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Plugin/views/filter/Selective.php b/src/Plugin/views/filter/Selective.php index 66e3523..1a7bdaa 100644 --- a/src/Plugin/views/filter/Selective.php +++ b/src/Plugin/views/filter/Selective.php @@ -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; @@ -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; @@ -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'], ); @@ -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; @@ -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 []; } @@ -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 []; } @@ -469,7 +469,7 @@ protected function getOids() { } if (NULL !== $value) { - $oids[$key] = SafeMarkup::checkPlain($value); + $oids[$key] = Html::escape($value); } } } @@ -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; diff --git a/views_selective_filters.info.yml b/views_selective_filters.info.yml index db5a88b..414f927 100644 --- a/views_selective_filters.info.yml +++ b/views_selective_filters.info.yml @@ -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 From 40f5669ccbce1399da74f1abd790cf8cbb4bac05 Mon Sep 17 00:00:00 2001 From: Amit Biswas Date: Fri, 6 Aug 2021 13:09:21 +0600 Subject: [PATCH 2/2] TSM-448: Maintenance: Fixed display_options error --- src/Plugin/views/filter/Selective.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/views/filter/Selective.php b/src/Plugin/views/filter/Selective.php index 1a7bdaa..419b788 100644 --- a/src/Plugin/views/filter/Selective.php +++ b/src/Plugin/views/filter/Selective.php @@ -367,7 +367,7 @@ 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]);