Created
June 10, 2017 09:49
-
-
Save rileyrg/4d2862568854b74cd5238e145b99542e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function renderFilteredPersonList(Request $request, QueryBuilder $queryB, $resetRoute) | |
{ | |
$personForm = $this->createForm(PersonFilterType::class, null, [ | |
'method' => 'GET' | |
]); | |
$personForm->handleRequest($request); | |
if ($personForm->get('reset')->isClicked()) { | |
$this->addFlash( | |
'alert-warning', | |
'filter.cleared' | |
); | |
return new RedirectResponse($request->getPathInfo()); | |
} | |
if ($request->query->has($personForm->getName())) { | |
$qb_updater = $this->get('lexik_form_filter.query_builder_updater'); | |
$qb_updater->setParts(array( | |
'__root__' => 'p', | |
'p.adressData' => 'a', | |
'p.adminAdressData' => 'aa', | |
'p.eyeColor' => 'e' | |
)); | |
$qb_updater->addFilterConditions($personForm, $queryB); | |
if ($personForm->get('search')->isClicked()) { | |
$this->addFlash( | |
'alert-success', | |
'filter.applied' | |
); | |
} | |
} | |
$paginator = $this->get('knp_paginator'); | |
$pagination = $paginator->paginate( | |
$queryB, | |
// $queryB->getQuery()->setHint( | |
// 'knp_paginator.count', | |
// $this->getParameter("paginator.limit")?:10000000 | |
// ), // ->setMaxResults(10), | |
$request->query->getInt('page', 1)/*page number*/, | |
5/*limit per page*/, | |
array('defaultSortFieldName' => 'p.surname', 'defaultSortDirection' => 'asc') | |
); | |
// $res=$personForm->getNormData(); | |
// array_map('utf8_encode', $res); | |
// $j = json_encode(§res); | |
// dump($j); | |
// | |
// parameters to template | |
return $this->render( | |
'person/person.list.html.twig', | |
array( | |
'personForm' => $personForm->createView(), | |
'pagination' => $pagination | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment