X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FRepository%2FTagRepository.php;h=ac3145a1dc8896d5ec8a980f3fee4769d37817ed;hb=57162494557c5eac938a7d6800ac1b112f73efc9;hp=51f1cd42924b22a88eb879fd6b5b3b14cfff058f;hpb=4919584b8758b23e127536b686776c1c41b3d215;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 51f1cd42..ac3145a1 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -11,7 +11,7 @@ class TagRepository extends EntityRepository /** * Find Tags. * - * @param int $userId + * @param int $userId * * @return array */ @@ -24,4 +24,21 @@ class TagRepository extends EntityRepository return new Pagerfanta($pagerAdapter); } + + /** + * Find a tag by its label and its owner. + * + * @param string $label + * @param int $userId + * + * @return Tag|null + */ + public function findOneByLabelAndUserId($label, $userId) + { + return $this->createQueryBuilder('t') + ->where('t.label = :label')->setParameter('label', $label) + ->andWhere('t.user = :user_id')->setParameter('user_id', $userId) + ->getQuery() + ->getOneOrNullResult(); + } }