$query->setResultCacheLifetime($cacheLifeTime);
}
- return count($query->getArrayResult());
+ return \count($query->getArrayResult());
}
/**
return $tags;
}
+ /**
+ * Find all tags (flat) per user with nb entries.
+ *
+ * @param int $userId
+ *
+ * @return array
+ */
+ public function findAllFlatTagsWithNbEntries($userId)
+ {
+ 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();
+ }
+
/**
* Used only in test case to get a tag for our entry.
*