aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2017-06-10 15:31:57 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-06-10 15:31:57 +0200
commit1112e54772c9308ee3d7417869b5b8ef9b2b9812 (patch)
tree1d4341b1a4889baf5c934dc2064a4f4e982f9947 /src/Wallabag/CoreBundle/Repository/EntryRepository.php
parente8911f7c09fa9d8009d7c7ee9fb0c181d2ffbc31 (diff)
downloadwallabag-1112e54772c9308ee3d7417869b5b8ef9b2b9812.tar.gz
wallabag-1112e54772c9308ee3d7417869b5b8ef9b2b9812.tar.zst
wallabag-1112e54772c9308ee3d7417869b5b8ef9b2b9812.zip
Add public filter/field in the API
Listing entries can now be filtered by “public”. Creating or patching an entry can now set is to public or remove the public. Entry response now include “is_public” boolean field
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 6972e974..9bda4e15 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -135,6 +135,7 @@ class EntryRepository extends EntityRepository
135 * @param int $userId 135 * @param int $userId
136 * @param bool $isArchived 136 * @param bool $isArchived
137 * @param bool $isStarred 137 * @param bool $isStarred
138 * @param bool $isPublic
138 * @param string $sort 139 * @param string $sort
139 * @param string $order 140 * @param string $order
140 * @param int $since 141 * @param int $since
@@ -142,18 +143,22 @@ class EntryRepository extends EntityRepository
142 * 143 *
143 * @return array 144 * @return array
144 */ 145 */
145 public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '') 146 public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '')
146 { 147 {
147 $qb = $this->createQueryBuilder('e') 148 $qb = $this->createQueryBuilder('e')
148 ->leftJoin('e.tags', 't') 149 ->leftJoin('e.tags', 't')
149 ->where('e.user =:userId')->setParameter('userId', $userId); 150 ->where('e.user =:userId')->setParameter('userId', $userId);
150 151
151 if (null !== $isArchived) { 152 if (null !== $isArchived) {
152 $qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', (bool) $isArchived); 153 $qb->andWhere('e.isArchived = :isArchived')->setParameter('isArchived', (bool) $isArchived);
153 } 154 }
154 155
155 if (null !== $isStarred) { 156 if (null !== $isStarred) {
156 $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred); 157 $qb->andWhere('e.isStarred = :isStarred')->setParameter('isStarred', (bool) $isStarred);
158 }
159
160 if (null !== $isPublic) {
161 $qb->andWhere('e.uid IS '.(true === $isPublic ? 'NOT' : '').' NULL');
157 } 162 }
158 163
159 if ($since > 0) { 164 if ($since > 0) {