aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2015-02-04 18:12:13 +0100
committerNicolas Lœuillet <nicolas@loeuillet.org>2015-02-04 18:12:13 +0100
commit6079aaa33dc78772e497725d7247c371b80b5578 (patch)
treeeed33e91176768d7c858bb83e23fde6ea4475da5 /src
parent6e334aba689f891a229c8a57f908f10dad5b3759 (diff)
downloadwallabag-6079aaa33dc78772e497725d7247c371b80b5578.tar.gz
wallabag-6079aaa33dc78772e497725d7247c371b80b5578.tar.zst
wallabag-6079aaa33dc78772e497725d7247c371b80b5578.zip
change delete status for GET /api/entries method
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php8
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntriesRepository.php7
2 files changed, 8 insertions, 7 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
index 5f56e0fc..55906ce0 100644
--- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
@@ -17,8 +17,8 @@ class WallabagRestController extends Controller
17 * 17 *
18 * @ApiDoc( 18 * @ApiDoc(
19 * parameters={ 19 * parameters={
20 * {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by archived status."}, 20 * {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', all entries by default", "description"="filter by archived status."},
21 * {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by starred status."}, 21 * {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', all entries by default", "description"="filter by starred status."},
22 * {"name"="delete", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by deleted status."}, 22 * {"name"="delete", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by deleted status."},
23 * {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."}, 23 * {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."},
24 * {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."}, 24 * {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."},
@@ -31,11 +31,9 @@ class WallabagRestController extends Controller
31 */ 31 */
32 public function getEntriesAction(Request $request) 32 public function getEntriesAction(Request $request)
33 { 33 {
34 // TODO isArchived, isStarred et isDeleted ne doivent pas avoir de valeur par défaut
35 // TODO Si on ne passe rien, on ne filtre pas sur le statut.
36 $isArchived = $request->query->get('archive'); 34 $isArchived = $request->query->get('archive');
37 $isStarred = $request->query->get('star'); 35 $isStarred = $request->query->get('star');
38 $isDeleted = $request->query->get('delete'); 36 $isDeleted = $request->query->get('delete', 0);
39 $sort = $request->query->get('sort', 'created'); 37 $sort = $request->query->get('sort', 'created');
40 $order = $request->query->get('order', 'desc'); 38 $order = $request->query->get('order', 'desc');
41 $page = $request->query->get('page', 1); 39 $page = $request->query->get('page', 1);
diff --git a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php
index aaca4251..dd92d520 100644
--- a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php
@@ -86,8 +86,7 @@ class EntriesRepository extends EntityRepository
86 //TODO tous les paramètres ne sont pas utilisés, à corriger 86 //TODO tous les paramètres ne sont pas utilisés, à corriger
87 $qb = $this->createQueryBuilder('e') 87 $qb = $this->createQueryBuilder('e')
88 ->select('e') 88 ->select('e')
89 ->where('e.userId =:userId')->setParameter('userId', $userId) 89 ->where('e.userId =:userId')->setParameter('userId', $userId);
90 ->andWhere('e.isDeleted=0');
91 90
92 if (!is_null($isArchived)) { 91 if (!is_null($isArchived)) {
93 $qb->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived); 92 $qb->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived);
@@ -97,6 +96,10 @@ class EntriesRepository extends EntityRepository
97 $qb->andWhere('e.isFav =:isStarred')->setParameter('isStarred', $isStarred); 96 $qb->andWhere('e.isFav =:isStarred')->setParameter('isStarred', $isStarred);
98 } 97 }
99 98
99 if (!is_null($isDeleted)) {
100 $qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', $isDeleted);
101 }
102
100 return $qb 103 return $qb
101 ->getQuery() 104 ->getQuery()
102 ->getResult(Query::HYDRATE_ARRAY); 105 ->getResult(Query::HYDRATE_ARRAY);