mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
adding pagination on search + renaming option
This commit is contained in:
parent
f442bf54b7
commit
10ea0c77e7
@ -74,3 +74,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if preview == false %}
|
||||||
|
{{ chill_pagination(paginator) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
|
|||||||
use ContainerAwareTrait;
|
use ContainerAwareTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var EntityManagerInterface
|
* @var EntityManagerInterface
|
||||||
*/
|
*/
|
||||||
private $em;
|
private $em;
|
||||||
@ -49,7 +49,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var AuthorizationHelper
|
* @var AuthorizationHelper
|
||||||
*/
|
*/
|
||||||
private $helper;
|
private $helper;
|
||||||
|
|
||||||
@ -63,8 +63,8 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
|
|||||||
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
TokenStorage $tokenStorage,
|
TokenStorage $tokenStorage,
|
||||||
AuthorizationHelper $helper,
|
AuthorizationHelper $helper,
|
||||||
PaginatorFactory $paginatorFactory)
|
PaginatorFactory $paginatorFactory)
|
||||||
{
|
{
|
||||||
@ -112,20 +112,21 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
|
|||||||
$total = $this->count($terms);
|
$total = $this->count($terms);
|
||||||
$paginator = $this->paginatorFactory->create($total);
|
$paginator = $this->paginatorFactory->create($total);
|
||||||
|
|
||||||
return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig',
|
return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig',
|
||||||
array(
|
array(
|
||||||
'persons' => $this->search($terms, $start, $limit, $options),
|
'persons' => $this->search($terms, $start, $limit, $options),
|
||||||
'pattern' => $this->recomposePattern($terms, array('nationality',
|
'pattern' => $this->recomposePattern($terms, array('nationality',
|
||||||
'firstname', 'lastname', 'birthdate', 'gender'), $terms['_domain']),
|
'firstname', 'lastname', 'birthdate', 'gender'), $terms['_domain']),
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'search_name' => self::NAME,
|
'search_name' => self::NAME,
|
||||||
'preview' => $options[SearchInterface::SEARCH_PREVIEW]
|
'preview' => $options[SearchInterface::SEARCH_PREVIEW_OPTION],
|
||||||
|
'paginator' => $paginator
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $pattern
|
* @param string $pattern
|
||||||
* @param int $start
|
* @param int $start
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
@ -161,11 +162,11 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
|
|||||||
private $_cacheQuery = array();
|
private $_cacheQuery = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param array $terms
|
* @param array $terms
|
||||||
* @return \Doctrine\ORM\QueryBuilder
|
* @return \Doctrine\ORM\QueryBuilder
|
||||||
*/
|
*/
|
||||||
protected function createQuery(array $terms)
|
protected function createQuery(array $terms)
|
||||||
{
|
{
|
||||||
//get from cache
|
//get from cache
|
||||||
$cacheKey = md5(serialize($terms));
|
$cacheKey = md5(serialize($terms));
|
||||||
@ -237,7 +238,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
//restraint center for security
|
//restraint center for security
|
||||||
$reachableCenters = $this->helper->getReachableCenters($this->user,
|
$reachableCenters = $this->helper->getReachableCenters($this->user,
|
||||||
new Role('CHILL_PERSON_SEE'));
|
new Role('CHILL_PERSON_SEE'));
|
||||||
$qb->andWhere($qb->expr()
|
$qb->andWhere($qb->expr()
|
||||||
->in('p.center', ':centers'))
|
->in('p.center', ':centers'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user