'desc']): array { $qb = $this->createQueryBuilder('a'); $qb->select('a'); if (!$allowNullScope) { $qb ->where($qb->expr()->in('a.scope', ':scopes')) ->setParameter('scopes', $scopes); } else { $qb ->where( $qb->expr()->orX( $qb->expr()->in('a.scope', ':scopes'), $qb->expr()->isNull('a.scope') ) ) ->setParameter('scopes', $scopes); } $qb ->andWhere( $qb->expr()->eq('a.accompanyingPeriod', ':period') ) ->setParameter('period', $period); foreach ($orderBy as $k => $dir) { $qb->addOrderBy('a.' . $k, $dir); } $qb->setMaxResults($limit)->setFirstResult($offset); return $qb->getQuery()->getResult(); } /** * @return Activity[] */ public function findByPersonImplied(Person $person, array $scopes, ?array $orderBy = ['date' => 'DESC'], ?int $limit = 100, ?int $offset = 0): array { $qb = $this->createQueryBuilder('a'); $qb->select('a'); $qb ->where($qb->expr()->in('a.scope', ':scopes')) ->setParameter('scopes', $scopes) ->andWhere( $qb->expr()->orX( $qb->expr()->eq('a.person', ':person'), ':person MEMBER OF a.persons' ) ) ->setParameter('person', $person); foreach ($orderBy as $k => $dir) { $qb->addOrderBy('a.' . $k, $dir); } $qb->setMaxResults($limit)->setFirstResult($offset); return $qb->getQuery()->getResult(); } }