Skip to content

Instantly share code, notes, and snippets.

@navitronic
Created December 7, 2011 23:39
Show Gist options
  • Save navitronic/1445318 to your computer and use it in GitHub Desktop.
Save navitronic/1445318 to your computer and use it in GitHub Desktop.
/**
* @Route("/school/search/", name="school_search")
* @Template("FlintSAKGFKitchenGardenProfileBundle:Default:school-search.html.twig")
* @param \Symfony\Component\HttpFoundation\Request $request
* @return array
*/
public function searchAction(Request $request)
{
$schoolSearch = $this->getSchoolSearch($request);
$form = $this->createForm(new Form\SchoolSearchType(), $schoolSearch);
$returnArray = array('schoolSearch' => $schoolSearch);
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
}
if ($schoolSearch->isValid()){
$schoolSearchService = $this->get('flint_sakgf_kitchen_garden_profile.school_search');
$query = $schoolSearchService->getSearchQuery($schoolSearch);
$pager = Pager::get($query, $request, self::SEARCH_PER_PAGE);
$returnArray['results'] = $pager;
$request->getSession()->setFlash('schoolSearch', $schoolSearch);
}
$returnArray['form'] = $form->createView();
// return amalgamated array.
return $returnArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment