- $tags = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Tag')
- ->findAllTags($this->getUser()->getId());
-
- $flatTags = [];
-
- foreach ($tags as $tag) {
- $nbEntries = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->countAllEntriesByUserIdAndTagId($this->getUser()->getId(), $tag->getId());
-
- $flatTags[] = [
- 'id' => $tag->getId(),
- 'label' => $tag->getLabel(),
- 'slug' => $tag->getSlug(),
- 'nbEntries' => $nbEntries,
- ];
- }
+ $tags = $this->get('wallabag_core.tag_repository')
+ ->findAllFlatTagsWithNbEntries($this->getUser()->getId());