From 55e259c07a6ca629302956e583db228c22c95661 Mon Sep 17 00:00:00 2001 From: ant Date: Wed, 8 Jan 2025 10:50:37 -0800 Subject: [PATCH] fix: redirect search to google (#1738) * fix: redirect search to google * chore: cleanup --- .../custom/sfgov_search/src/Form/GoogleSearchForm.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/modules/custom/sfgov_search/src/Form/GoogleSearchForm.php b/web/modules/custom/sfgov_search/src/Form/GoogleSearchForm.php index 16fdfaefa..dc130e199 100644 --- a/web/modules/custom/sfgov_search/src/Form/GoogleSearchForm.php +++ b/web/modules/custom/sfgov_search/src/Form/GoogleSearchForm.php @@ -6,6 +6,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\RedirectResponse; class GoogleSearchForm extends FormBase { @@ -92,8 +93,10 @@ public function buildForm(array $form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) { $search = $form_state->getValues()['keys']; - $form_state->setRedirect('search.view_google_json_api_search', ['keys' => $search], [ - 'language' => $this->languageManager->getCurrentLanguage(), - ]); + $google_search_url = \Drupal\Core\Url::fromUri('https://www.google.com/search', [ + 'query' => ['q' => $search . ' site:sf.gov OR site:sfgov.org'], + ])->toString(); + $response = new RedirectResponse($google_search_url); + $response->send(); } }