improve activity

This commit is contained in:
2021-06-29 20:51:08 +02:00
parent 7dc70baf57
commit d9c1f52894
7 changed files with 60 additions and 29 deletions

View File

@@ -38,5 +38,30 @@ class ActivityRepository extends ServiceEntityRepository
{
parent::__construct($registry, Activity::class);
}
public function findByPersonImplied($person, array $scopes, $orderBy = [ 'date' => 'DESC'], $limit = 100, $offset = 0)
{
$qb = $this->createQueryBuilder('a');
$qb->select('a');
$qb
// TODO add acl
//->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);
}
return $qb->getQuery()
->getResult();
}
}