- $qb = $this->createQueryBuilder('e')
- ->select('e')
- ->setFirstResult($firstResult)
- ->setMaxResults($maxResults)
- ->leftJoin('e.user', 'u')
- ->where('e.isStarred = true')
- ->andWhere('u.id =:userId')->setParameter('userId', $userId)
- ->orderBy('e.createdAt', 'desc')
- ->getQuery();
-
- $paginator = new Paginator($qb);
-
- return $paginator;
+ return $this->createQueryBuilder('t')
+ ->select('t.id, t.label, t.slug, count(e.id) as nbEntries')
+ ->distinct(true)
+ ->leftJoin('t.entries', 'e')
+ ->where('e.user = :userId')
+ ->groupBy('t.id')
+ ->orderBy('t.slug')
+ ->setParameter('userId', $userId)
+ ->getQuery()
+ ->getArrayResult();