simplify alterquery

This commit is contained in:
Mathieu Jaumotte 2023-01-30 14:35:48 +01:00
parent 896b4cdfe3
commit d1e8e6c18e

View File

@ -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