From f6e6b7ccc16d5e3e3bef8e510961f246a26efc4f Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Tue, 28 Jan 2025 17:54:13 -0800 Subject: [PATCH 1/3] Add warning if view has exposed filters. --- quant.module | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/quant.module b/quant.module index 150bc31a..ac0dff00 100644 --- a/quant.module +++ b/quant.module @@ -17,6 +17,7 @@ use Drupal\quant\Plugin\QueueItem\RouteItem; use Drupal\quant\QuantQueueFactory; use Drupal\quant\Seed; use Drupal\quant\Utility; +use Drupal\views\ViewExecutable; /** * Implements hook_menu_local_tasks_alter(). @@ -501,3 +502,16 @@ function quant_preprocess_views_view_table(&$variables) { } } } + +/** + * Implements hook_preprocess_views_view(). + */ +function quant_preprocess_views_view(array &$variables) { + /** @var ViewExecutable $view */ + $view = $variables['view']; + + // If the view has exposed filters, add a warning for admins. + if ($view->exposed_data && \Drupal::currentUser()->hasRole('administrator')) { + \Drupal::messenger()->addWarning(t('The view (@view_id) on this page has exposed filters which need special handling for a static website.
Review the documentation for your options.', ['@view_id' => $view->id()])); + } +} From 4346e1d7379c8e8c94b1dc9a09a95e38d9296452 Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Tue, 28 Jan 2025 20:49:34 -0800 Subject: [PATCH 2/3] Updated warning text. --- quant.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quant.module b/quant.module index ac0dff00..6acc973d 100644 --- a/quant.module +++ b/quant.module @@ -512,6 +512,6 @@ function quant_preprocess_views_view(array &$variables) { // If the view has exposed filters, add a warning for admins. if ($view->exposed_data && \Drupal::currentUser()->hasRole('administrator')) { - \Drupal::messenger()->addWarning(t('The view (@view_id) on this page has exposed filters which need special handling for a static website.
Review the documentation for your options.', ['@view_id' => $view->id()])); + \Drupal::messenger()->addWarning(t('The view (@view_id) on this page has exposed filters which need special handling for a static website.
See the documentation for your options.', ['@view_id' => $view->id()])); } } From 9f22756b63fe12da09e773ee0e80b7a2f7b31ea0 Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Tue, 28 Jan 2025 20:53:54 -0800 Subject: [PATCH 3/3] Fix linting. --- quant.module | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/quant.module b/quant.module index 6acc973d..c535fa5f 100644 --- a/quant.module +++ b/quant.module @@ -17,7 +17,6 @@ use Drupal\quant\Plugin\QueueItem\RouteItem; use Drupal\quant\QuantQueueFactory; use Drupal\quant\Seed; use Drupal\quant\Utility; -use Drupal\views\ViewExecutable; /** * Implements hook_menu_local_tasks_alter(). @@ -507,7 +506,7 @@ function quant_preprocess_views_view_table(&$variables) { * Implements hook_preprocess_views_view(). */ function quant_preprocess_views_view(array &$variables) { - /** @var ViewExecutable $view */ + /** @var \Drupal\views\ViewExecutable $view */ $view = $variables['view']; // If the view has exposed filters, add a warning for admins.