I have so far 2 queries which are similar:
the first one I use when user is ROLE_REDAC
$qb = $this->createQueryBuilder('a'); $qb->LeftJoin('a.ArticlePhrases','ap') ->addSelect('ap') ->where( $qb->expr()->andX( $qb->expr()->eq('ap.order', '?1'), $qb->expr()->eq('a.author', '?2') ) ) ->setParameters(//... ); The second one when user is ROLE_ADMIN
$qb = $this->createQueryBuilder('a'); $qb->LeftJoin('a.ArticlePhrases','ap') ->addSelect('ap') ->where( $qb->expr()->andX( $qb->expr()->eq('ap.order', '?1') ) ) ->setParameters(... )); There are not much difference. is it possible to call from the controller the same repository fonction and that this fonction adapt whether the actual user is ROLE_REDAC or ROLE_ADM? if yes how can I do that?