mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
issue641: simplify alterQuery where clause in concerned filters
This commit is contained in:
@@ -15,7 +15,6 @@ use Chill\ActivityBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\PersonBundle\Form\Type\Select2SocialActionType;
|
||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
@@ -36,22 +35,14 @@ class BySocialActionFilter implements FilterInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
if (!in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.socialActions', 'actsocialaction');
|
||||
}
|
||||
|
||||
$clause = $qb->expr()->in('actsocialaction.id', ':socialactions');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('socialactions', $data['accepted_socialactions']);
|
||||
$qb ->andWhere($clause)
|
||||
->setParameter('socialactions', $data['accepted_socialactions']);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
|
@@ -15,7 +15,6 @@ use Chill\ActivityBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\PersonBundle\Form\Type\Select2SocialIssueType;
|
||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
@@ -36,22 +35,14 @@ class BySocialIssueFilter implements FilterInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
if (!in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
||||
$qb->join('activity.socialIssues', 'actsocialissue');
|
||||
}
|
||||
|
||||
$clause = $qb->expr()->in('actsocialissue.id', ':socialissues');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('socialissues', $data['accepted_socialissues']);
|
||||
$qb ->andWhere($clause)
|
||||
->setParameter('socialissues', $data['accepted_socialissues']);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
|
Reference in New Issue
Block a user