Skip to content

Instantly share code, notes, and snippets.

@rccc
Last active June 5, 2023 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rccc/cc6aa026ae0c3d01a487ad2068c35d10 to your computer and use it in GitHub Desktop.
Save rccc/cc6aa026ae0c3d01a487ad2068c35d10 to your computer and use it in GitHub Desktop.
Form responses must redirect to another location
public function search(int $page =1, Request $request, SessionInterface $session, SearchService $searchService)
{
$searchType = null;
$result = null;
$queryList = [];
$tmp = [];
$result = $searchService->handleSearchRequest($request, $page);
$selection = $session->get('selection');
if($result)
{
if($searchService->getDisplay() == "grid")
{
$template = 'search/result_grid.html.twig';
}
else
{
$template = 'search/result.html.twig';
}
return $this->renderForm($template, [
'result' => $result,
'total' => $result[0]['full_count'],
'page' => $page,
'selection' => $selection,
'searchService' => $searchService->toArray()
]);
}
return $this->redirectToRoute('index');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment