mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 06:14:23 +00:00
renaming SearchInterface::SEARCH_PREVIEW => SEARCH_PREVIEW_OPTION
This commit is contained in:
parent
2a10929d36
commit
82b0fad8de
@ -15,17 +15,17 @@ use Chill\MainBundle\Search\SearchInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Search within Events.
|
* Search within Events.
|
||||||
*
|
*
|
||||||
* available terms :
|
* available terms :
|
||||||
* - name: to search within the name
|
* - name: to search within the name
|
||||||
* - date: search the event at a the given date
|
* - date: search the event at a the given date
|
||||||
* - date-from: search the event after the given date
|
* - date-from: search the event after the given date
|
||||||
* - date-to : search the event before the given date
|
* - date-to : search the event before the given date
|
||||||
*
|
*
|
||||||
* Default terms search within the name, but the term "name" has precedence. This
|
* Default terms search within the name, but the term "name" has precedence. This
|
||||||
* means that if the search string is `@event xyz name:"abc"`, the searched
|
* means that if the search string is `@event xyz name:"abc"`, the searched
|
||||||
* string will be "abc" and not xyz
|
* string will be "abc" and not xyz
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
* @author Champs Libres <info@champs-libres.coop>
|
* @author Champs Libres <info@champs-libres.coop>
|
||||||
@ -34,7 +34,7 @@ class EventSearch extends AbstractSearch
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
private $er;
|
private $er;
|
||||||
@ -47,7 +47,7 @@ class EventSearch extends AbstractSearch
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var AuthorizationHelper
|
* @var AuthorizationHelper
|
||||||
*/
|
*/
|
||||||
private $helper;
|
private $helper;
|
||||||
|
|
||||||
@ -95,25 +95,25 @@ class EventSearch extends AbstractSearch
|
|||||||
return 3000;
|
return 3000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderResult(array $terms, $start = 0, $limit = 50,
|
public function renderResult(array $terms, $start = 0, $limit = 50,
|
||||||
array $options = array())
|
array $options = array())
|
||||||
{
|
{
|
||||||
$total = $this->count($terms);
|
$total = $this->count($terms);
|
||||||
$paginator = $this->paginationFactory->create($total);
|
$paginator = $this->paginationFactory->create($total);
|
||||||
|
|
||||||
return $this->templating->render('ChillEventBundle:Event:list.html.twig',
|
return $this->templating->render('ChillEventBundle:Event:list.html.twig',
|
||||||
array(
|
array(
|
||||||
'events' => $this->search($terms, $start, $limit, $options),
|
'events' => $this->search($terms, $start, $limit, $options),
|
||||||
'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']),
|
'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']),
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'preview' => $options[SearchInterface::SEARCH_PREVIEW],
|
'preview' => $options[SearchInterface::SEARCH_PREVIEW_OPTION],
|
||||||
'paginator' => $paginator,
|
'paginator' => $paginator,
|
||||||
'search_name' => self::NAME
|
'search_name' => self::NAME
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getAvailableTerms()
|
protected function getAvailableTerms()
|
||||||
{
|
{
|
||||||
return array('date-from', 'date-to', 'name', 'date');
|
return array('date-from', 'date-to', 'name', 'date');
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ class EventSearch extends AbstractSearch
|
|||||||
$n = 0;
|
$n = 0;
|
||||||
$orWhere = $qb->expr()->orX();
|
$orWhere = $qb->expr()->orX();
|
||||||
foreach ($reachableCenters as $center) {
|
foreach ($reachableCenters as $center) {
|
||||||
$circles = $this->helper->getReachableScopes($this->user,
|
$circles = $this->helper->getReachableScopes($this->user,
|
||||||
new Role('CHILL_EVENT_SEE'), $center);
|
new Role('CHILL_EVENT_SEE'), $center);
|
||||||
$where = $qb->expr()->andX(
|
$where = $qb->expr()->andX(
|
||||||
$qb->expr()->eq('e.center', ':center_'.$n),
|
$qb->expr()->eq('e.center', ':center_'.$n),
|
||||||
@ -180,7 +180,7 @@ class EventSearch extends AbstractSearch
|
|||||||
|
|
||||||
$where = $qb->expr()->like('UNACCENT(LOWER(e.name))', ':name');
|
$where = $qb->expr()->like('UNACCENT(LOWER(e.name))', ':name');
|
||||||
$qb->setParameter('name', '%'.$name.'%');
|
$qb->setParameter('name', '%'.$name.'%');
|
||||||
$qb->andWhere($where);
|
$qb->andWhere($where);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($terms['date'])) {
|
if (isset($terms['date'])) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user