diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index ca71970b..c6763a40 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -223,4 +223,29 @@ class EntryRepository extends EntityRepository | |||
223 | ->getQuery() | 223 | ->getQuery() |
224 | ->getResult(); | 224 | ->getResult(); |
225 | } | 225 | } |
226 | |||
227 | /** | ||
228 | * Find an entry by its url and its owner. | ||
229 | * If it exists, return the entry otherwise return false. | ||
230 | * | ||
231 | * @param $url | ||
232 | * @param $userId | ||
233 | * | ||
234 | * @return array|bool | ||
235 | */ | ||
236 | public function existByUrlAndUserId($url, $userId) | ||
237 | { | ||
238 | $res = $this->createQueryBuilder('e') | ||
239 | ->select('e.id, e.createdAt') | ||
240 | ->where('e.url = :url')->setParameter('url', $url) | ||
241 | ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) | ||
242 | ->getQuery() | ||
243 | ->getResult(); | ||
244 | |||
245 | if (count($res)) { | ||
246 | return current($res); | ||
247 | } | ||
248 | |||
249 | return false; | ||
250 | } | ||
226 | } | 251 | } |