X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FRepository%2FEntryRepository.php;h=23d1e37e2deda7aa25a53823a417ece9741edf5f;hb=4c8dfe335a27c222fd37e4c2fb3c94d0b0bf8a61;hp=bfd079377ac783bdd4c2e0e2f84cb3f2e9d0496b;hpb=b19df31d78d881a43bcf6b3215e5fc3781e8e8aa;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index bfd07937..23d1e37e 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -39,7 +39,34 @@ class EntryRepository extends EntityRepository return $this ->getSortedQueryBuilderByUser($userId) ->andWhere('e.isArchived = false') - ; + ; + } + + /** + * Retrieves entries with the same domain. + * + * @param int $userId + * @param int $entryId + * + * @return QueryBuilder + */ + public function getBuilderForSameDomainByUser($userId, $entryId) + { + $queryBuilder = $this->createQueryBuilder('e'); + + return $this + ->getSortedQueryBuilderByUser($userId) + ->andWhere('e.id <> :entryId')->setParameter('entryId', $entryId) + ->andWhere( + $queryBuilder->expr()->in( + 'e.domainName', + $this + ->createQueryBuilder('e2') + ->select('e2.domainName') + ->where('e2.id = :entryId')->setParameter('entryId', $entryId) + ->getDQL() + ) + ); } /**