diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 45366623..f5089729 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -347,6 +347,30 @@ class EntryRepository extends EntityRepository | |||
347 | } | 347 | } |
348 | 348 | ||
349 | /** | 349 | /** |
350 | * Find an entry by its hashed url and its owner. | ||
351 | * If it exists, return the entry otherwise return false. | ||
352 | * | ||
353 | * @param string $hashedUrl Url hashed using sha1 | ||
354 | * @param int $userId | ||
355 | * | ||
356 | * @return Entry|bool | ||
357 | */ | ||
358 | public function findByHashedUrlAndUserId($hashedUrl, $userId) | ||
359 | { | ||
360 | $res = $this->createQueryBuilder('e') | ||
361 | ->where('e.hashedUrl = :hashed_url')->setParameter('hashed_url', $hashedUrl) | ||
362 | ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) | ||
363 | ->getQuery() | ||
364 | ->getResult(); | ||
365 | |||
366 | if (\count($res)) { | ||
367 | return current($res); | ||
368 | } | ||
369 | |||
370 | return false; | ||
371 | } | ||
372 | |||
373 | /** | ||
350 | * Count all entries for a user. | 374 | * Count all entries for a user. |
351 | * | 375 | * |
352 | * @param int $userId | 376 | * @param int $userId |