diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 9bda4e15..c27ee90c 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -11,21 +11,6 @@ use Wallabag\CoreBundle\Entity\Tag; | |||
11 | class EntryRepository extends EntityRepository | 11 | class EntryRepository extends EntityRepository |
12 | { | 12 | { |
13 | /** | 13 | /** |
14 | * Return a query builder to used by other getBuilderFor* method. | ||
15 | * | ||
16 | * @param int $userId | ||
17 | * | ||
18 | * @return QueryBuilder | ||
19 | */ | ||
20 | private function getBuilderByUser($userId) | ||
21 | { | ||
22 | return $this->createQueryBuilder('e') | ||
23 | ->andWhere('e.user = :userId')->setParameter('userId', $userId) | ||
24 | ->orderBy('e.createdAt', 'desc') | ||
25 | ; | ||
26 | } | ||
27 | |||
28 | /** | ||
29 | * Retrieves all entries for a user. | 14 | * Retrieves all entries for a user. |
30 | * | 15 | * |
31 | * @param int $userId | 16 | * @param int $userId |
@@ -108,7 +93,7 @@ class EntryRepository extends EntityRepository | |||
108 | 93 | ||
109 | // We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive | 94 | // We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive |
110 | $qb | 95 | $qb |
111 | ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%'.$term.'%') | 96 | ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%' . $term . '%') |
112 | ->leftJoin('e.tags', 't') | 97 | ->leftJoin('e.tags', 't') |
113 | ->groupBy('e.id'); | 98 | ->groupBy('e.id'); |
114 | 99 | ||
@@ -158,7 +143,7 @@ class EntryRepository extends EntityRepository | |||
158 | } | 143 | } |
159 | 144 | ||
160 | if (null !== $isPublic) { | 145 | if (null !== $isPublic) { |
161 | $qb->andWhere('e.uid IS '.(true === $isPublic ? 'NOT' : '').' NULL'); | 146 | $qb->andWhere('e.uid IS ' . (true === $isPublic ? 'NOT' : '') . ' NULL'); |
162 | } | 147 | } |
163 | 148 | ||
164 | if ($since > 0) { | 149 | if ($since > 0) { |
@@ -340,7 +325,7 @@ class EntryRepository extends EntityRepository | |||
340 | ->where('e.user=:userId')->setParameter('userId', $userId) | 325 | ->where('e.user=:userId')->setParameter('userId', $userId) |
341 | ; | 326 | ; |
342 | 327 | ||
343 | return $qb->getQuery()->getSingleScalarResult(); | 328 | return (int) $qb->getQuery()->getSingleScalarResult(); |
344 | } | 329 | } |
345 | 330 | ||
346 | /** | 331 | /** |
@@ -360,7 +345,7 @@ class EntryRepository extends EntityRepository | |||
360 | ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId) | 345 | ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId) |
361 | ; | 346 | ; |
362 | 347 | ||
363 | return $qb->getQuery()->getSingleScalarResult(); | 348 | return (int) $qb->getQuery()->getSingleScalarResult(); |
364 | } | 349 | } |
365 | 350 | ||
366 | /** | 351 | /** |
@@ -414,4 +399,19 @@ class EntryRepository extends EntityRepository | |||
414 | ->getQuery() | 399 | ->getQuery() |
415 | ->getResult(); | 400 | ->getResult(); |
416 | } | 401 | } |
402 | |||
403 | /** | ||
404 | * Return a query builder to used by other getBuilderFor* method. | ||
405 | * | ||
406 | * @param int $userId | ||
407 | * | ||
408 | * @return QueryBuilder | ||
409 | */ | ||
410 | private function getBuilderByUser($userId) | ||
411 | { | ||
412 | return $this->createQueryBuilder('e') | ||
413 | ->andWhere('e.user = :userId')->setParameter('userId', $userId) | ||
414 | ->orderBy('e.createdAt', 'desc') | ||
415 | ; | ||
416 | } | ||
417 | } | 417 | } |