adding pagination on search + renaming option

This commit is contained in:
Julien Fastré 2016-08-25 22:16:46 +02:00
parent f442bf54b7
commit 10ea0c77e7
2 changed files with 17 additions and 11 deletions

View File

@ -74,3 +74,8 @@
</ul>
{% endif %}
{% if preview == false %}
{{ chill_pagination(paginator) }}
{% endif %}

View File

@ -36,7 +36,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
use ContainerAwareTrait;
/**
*
*
* @var EntityManagerInterface
*/
private $em;
@ -49,7 +49,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
/**
*
* @var AuthorizationHelper
* @var AuthorizationHelper
*/
private $helper;
@ -63,8 +63,8 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
public function __construct(
EntityManagerInterface $em,
TokenStorage $tokenStorage,
EntityManagerInterface $em,
TokenStorage $tokenStorage,
AuthorizationHelper $helper,
PaginatorFactory $paginatorFactory)
{
@ -112,20 +112,21 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
$total = $this->count($terms);
$paginator = $this->paginatorFactory->create($total);
return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig',
array(
return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig',
array(
'persons' => $this->search($terms, $start, $limit, $options),
'pattern' => $this->recomposePattern($terms, array('nationality',
'firstname', 'lastname', 'birthdate', 'gender'), $terms['_domain']),
'total' => $total,
'start' => $start,
'search_name' => self::NAME,
'preview' => $options[SearchInterface::SEARCH_PREVIEW]
'preview' => $options[SearchInterface::SEARCH_PREVIEW_OPTION],
'paginator' => $paginator
));
}
/**
*
*
* @param string $pattern
* @param int $start
* @param int $limit
@ -161,11 +162,11 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
private $_cacheQuery = array();
/**
*
*
* @param array $terms
* @return \Doctrine\ORM\QueryBuilder
*/
protected function createQuery(array $terms)
protected function createQuery(array $terms)
{
//get from cache
$cacheKey = md5(serialize($terms));
@ -237,7 +238,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
}
//restraint center for security
$reachableCenters = $this->helper->getReachableCenters($this->user,
$reachableCenters = $this->helper->getReachableCenters($this->user,
new Role('CHILL_PERSON_SEE'));
$qb->andWhere($qb->expr()
->in('p.center', ':centers'))