Skip to content

Commit

Permalink
fix: redirect search to google (#1738)
Browse files Browse the repository at this point in the history
* fix: redirect search to google

* chore: cleanup
  • Loading branch information
aekong authored Jan 8, 2025
1 parent 326d2e1 commit 55e259c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions web/modules/custom/sfgov_search/src/Form/GoogleSearchForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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();
}
}

1 comment on commit 55e259c

@aekong
Copy link
Collaborator Author

@aekong aekong commented on 55e259c Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visit Site

Created multidev environment ci-20868 for sfgov.

Please sign in to comment.