X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FRepository%2FTagRepository.php;h=41f616079dd53f69032512adf6a1bfb176b98657;hb=637aa17e6b52dd8021854a809053560a27caca72;hp=903a99cda3804bddfa61751cdf611a3c6a209e75;hpb=6d37a7e6c11666c2c220c9eb358a877f15bcfa0e;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 903a99cd..41f61607 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -6,5 +6,33 @@ use Doctrine\ORM\EntityRepository; class TagRepository extends EntityRepository { + /** + * Find Tags. + * + * @param int $userId + * + * @return array + */ + public function findAllTags($userId) + { + return $this->createQueryBuilder('t') + ->leftJoin('t.entries', 'e') + ->where('e.user = :userId')->setParameter('userId', $userId); + } + /** + * Used only in test case to get a tag for our entry. + * + * @return Tag + */ + public function findOneByEntryAndTagLabel($entry, $label) + { + return $this->createQueryBuilder('t') + ->leftJoin('t.entries', 'e') + ->where('e.id = :entryId')->setParameter('entryId', $entry->getId()) + ->andWhere('t.label = :label')->setParameter('label', $label) + ->setMaxResults(1) + ->getQuery() + ->getSingleResult(); + } }