mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
simplify alterquery
This commit is contained in:
parent
896b4cdfe3
commit
d1e8e6c18e
@ -52,18 +52,10 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
if (count($data['actionType']) > 0) {
|
||||
$clause = $qb->expr()->in('acpw.socialAction', ':actionType');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->setParameter('actionType', $data['actionType']);
|
||||
$qb
|
||||
->andWhere($qb->expr()->in('acpw.socialAction', ':actionType'))
|
||||
->setParameter('actionType', $data['actionType']);
|
||||
}
|
||||
|
||||
if (count($data['goal']) > 0) {
|
||||
@ -71,11 +63,9 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
$qb->join('acpw.goals', 'goal');
|
||||
}
|
||||
|
||||
$where->add(
|
||||
$qb->expr()->in('goal.id', ':goals')
|
||||
);
|
||||
|
||||
$qb->setParameter('goals', $data['goal']);
|
||||
$qb
|
||||
->andWhere($qb->expr()->in('goal.id', ':goals'))
|
||||
->setParameter('goals', $data['goal']);
|
||||
}
|
||||
|
||||
if (count($data['result']) > 0) {
|
||||
@ -83,14 +73,10 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
$qb->join('acpw.results', 'result');
|
||||
}
|
||||
|
||||
$where->add(
|
||||
$qb->expr()->in('result.id', ':results')
|
||||
);
|
||||
|
||||
$qb->setParameter('results', $data['result']);
|
||||
$qb
|
||||
->andWhere($qb->expr()->in('result.id', ':results'))
|
||||
->setParameter('results', $data['result']);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
|
Loading…
x
Reference in New Issue
Block a user