Skip to content

Commit 55e259c

Browse files
authored
fix: redirect search to google (#1738)
* fix: redirect search to google * chore: cleanup
1 parent 326d2e1 commit 55e259c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

web/modules/custom/sfgov_search/src/Form/GoogleSearchForm.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Drupal\Core\Form\FormStateInterface;
77
use Drupal\Core\Language\LanguageManagerInterface;
88
use Symfony\Component\DependencyInjection\ContainerInterface;
9+
use Symfony\Component\HttpFoundation\RedirectResponse;
910

1011
class GoogleSearchForm extends FormBase {
1112

@@ -92,8 +93,10 @@ public function buildForm(array $form, FormStateInterface $form_state) {
9293

9394
public function submitForm(array &$form, FormStateInterface $form_state) {
9495
$search = $form_state->getValues()['keys'];
95-
$form_state->setRedirect('search.view_google_json_api_search', ['keys' => $search], [
96-
'language' => $this->languageManager->getCurrentLanguage(),
97-
]);
96+
$google_search_url = \Drupal\Core\Url::fromUri('https://www.google.com/search', [
97+
'query' => ['q' => $search . ' site:sf.gov OR site:sfgov.org'],
98+
])->toString();
99+
$response = new RedirectResponse($google_search_url);
100+
$response->send();
98101
}
99102
}

0 commit comments

Comments
 (0)