aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index c27ee90c..eb5e3205 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -3,9 +3,10 @@
3namespace Wallabag\CoreBundle\Repository; 3namespace Wallabag\CoreBundle\Repository;
4 4
5use Doctrine\ORM\EntityRepository; 5use Doctrine\ORM\EntityRepository;
6use Doctrine\ORM\Query; 6use Doctrine\ORM\QueryBuilder;
7use Pagerfanta\Adapter\DoctrineORMAdapter; 7use Pagerfanta\Adapter\DoctrineORMAdapter;
8use Pagerfanta\Pagerfanta; 8use Pagerfanta\Pagerfanta;
9use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag; 10use Wallabag\CoreBundle\Entity\Tag;
10 11
11class EntryRepository extends EntityRepository 12class EntryRepository extends EntityRepository
@@ -74,7 +75,7 @@ class EntryRepository extends EntityRepository
74 * 75 *
75 * @param int $userId 76 * @param int $userId
76 * @param string $term 77 * @param string $term
77 * @param strint $currentRoute 78 * @param string $currentRoute
78 * 79 *
79 * @return QueryBuilder 80 * @return QueryBuilder
80 */ 81 */
@@ -126,7 +127,7 @@ class EntryRepository extends EntityRepository
126 * @param int $since 127 * @param int $since
127 * @param string $tags 128 * @param string $tags
128 * 129 *
129 * @return array 130 * @return Pagerfanta
130 */ 131 */
131 public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '') 132 public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '')
132 { 133 {
@@ -172,7 +173,7 @@ class EntryRepository extends EntityRepository
172 * 173 *
173 * @param int $userId 174 * @param int $userId
174 * 175 *
175 * @return Entry 176 * @return array
176 */ 177 */
177 public function findOneWithTags($userId) 178 public function findOneWithTags($userId)
178 { 179 {
@@ -329,26 +330,6 @@ class EntryRepository extends EntityRepository
329 } 330 }
330 331
331 /** 332 /**
332 * Count all entries for a tag and a user.
333 *
334 * @param int $userId
335 * @param int $tagId
336 *
337 * @return int
338 */
339 public function countAllEntriesByUserIdAndTagId($userId, $tagId)
340 {
341 $qb = $this->createQueryBuilder('e')
342 ->select('count(e.id)')
343 ->leftJoin('e.tags', 't')
344 ->where('e.user=:userId')->setParameter('userId', $userId)
345 ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId)
346 ;
347
348 return (int) $qb->getQuery()->getSingleScalarResult();
349 }
350
351 /**
352 * Remove all entries for a user id. 333 * Remove all entries for a user id.
353 * Used when a user want to reset all informations. 334 * Used when a user want to reset all informations.
354 * 335 *
@@ -374,7 +355,7 @@ class EntryRepository extends EntityRepository
374 * Get id and url from all entries 355 * Get id and url from all entries
375 * Used for the clean-duplicates command. 356 * Used for the clean-duplicates command.
376 */ 357 */
377 public function getAllEntriesIdAndUrl($userId) 358 public function findAllEntriesIdAndUrlByUserId($userId)
378 { 359 {
379 $qb = $this->createQueryBuilder('e') 360 $qb = $this->createQueryBuilder('e')
380 ->select('e.id, e.url') 361 ->select('e.id, e.url')
@@ -384,6 +365,23 @@ class EntryRepository extends EntityRepository
384 } 365 }
385 366
386 /** 367 /**
368 * @param int $userId
369 *
370 * @return array
371 */
372 public function findAllEntriesIdByUserId($userId = null)
373 {
374 $qb = $this->createQueryBuilder('e')
375 ->select('e.id');
376
377 if (null !== $userId) {
378 $qb->where('e.user = :userid')->setParameter(':userid', $userId);
379 }
380
381 return $qb->getQuery()->getArrayResult();
382 }
383
384 /**
387 * Find all entries by url and owner. 385 * Find all entries by url and owner.
388 * 386 *
389 * @param $url 387 * @param $url