diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-06-10 15:31:57 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-06-10 15:31:57 +0200 |
commit | 1112e54772c9308ee3d7417869b5b8ef9b2b9812 (patch) | |
tree | 1d4341b1a4889baf5c934dc2064a4f4e982f9947 /src/Wallabag/CoreBundle | |
parent | e8911f7c09fa9d8009d7c7ee9fb0c181d2ffbc31 (diff) | |
download | wallabag-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')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 4 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 365030c7..07d41ed8 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -687,6 +687,10 @@ class Entry | |||
687 | /** | 687 | /** |
688 | * Used in the entries filter so it's more explicit for the end user than the uid. | 688 | * Used in the entries filter so it's more explicit for the end user than the uid. |
689 | * | 689 | * |
690 | * @VirtualProperty | ||
691 | * @SerializedName("is_public") | ||
692 | * @Groups({"entries_for_user"}) | ||
693 | * | ||
690 | * @return bool | 694 | * @return bool |
691 | */ | 695 | */ |
692 | public function isPublic() | 696 | public function isPublic() |
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) { |