mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
parent
5bcff0cba4
commit
ca2d4db6f9
@ -13,6 +13,17 @@ use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
/**
|
||||
* Search within Events.
|
||||
*
|
||||
* available terms :
|
||||
* - name: to search within the name
|
||||
* - date: search the event at a the given date
|
||||
* - date-from: search the event after 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
|
||||
* means that if the search string is `@event xyz name:"abc"`, the searched
|
||||
* string will be "abc" and not xyz
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @author Champs Libres <info@champs-libres.coop>
|
||||
@ -65,7 +76,7 @@ class EventSearch extends AbstractSearch
|
||||
|
||||
public function isActiveByDefault()
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
@ -136,6 +147,39 @@ class EventSearch extends AbstractSearch
|
||||
$qb->andWhere($orWhere);
|
||||
}
|
||||
|
||||
if (isset($terms['name']) OR isset($terms['_default'])) {
|
||||
// the form with name:"xyz" has precedence
|
||||
$name = isset($terms['name']) ? $terms['name'] : $terms['_default'];
|
||||
|
||||
$where = $qb->expr()->like('UNACCENT(LOWER(e.name))', ':name');
|
||||
$qb->setParameter('name', '%'.$name.'%');
|
||||
$qb->andWhere($where);
|
||||
}
|
||||
|
||||
if (isset($terms['date'])) {
|
||||
$date = $this->parseDate($terms['date']);
|
||||
|
||||
$where = $qb->expr()->eq('e.date', ':date');
|
||||
$qb->setParameter('date', $date);
|
||||
$qb->andWhere($where);
|
||||
}
|
||||
|
||||
if (isset($terms['date-from'])) {
|
||||
$date = $this->parseDate($terms['date-from']);
|
||||
|
||||
$where = $qb->expr()->gte('e.date', ':datefrom');
|
||||
$qb->setParameter('datefrom', $date);
|
||||
$qb->andWhere($where);
|
||||
}
|
||||
|
||||
if (isset($terms['date-to'])) {
|
||||
$date = $this->parseDate($terms['date-to']);
|
||||
|
||||
$where = $qb->expr()->lte('e.date', ':dateto');
|
||||
$qb->setParameter('dateto', $date);
|
||||
$qb->andWhere($where);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $qb;
|
||||
|
Loading…
x
Reference in New Issue
Block a user