diff options
author | Nicolas Lœuillet <nicolas@loeuillet.org> | 2015-02-04 18:06:42 +0100 |
---|---|---|
committer | Nicolas Lœuillet <nicolas@loeuillet.org> | 2015-02-04 18:06:42 +0100 |
commit | 6e334aba689f891a229c8a57f908f10dad5b3759 (patch) | |
tree | f6c8ceb5dd611a1f2d2c3c0fd48ed76890e27d31 | |
parent | 42a9064620eb73eaa42928a22eeec86299d4a883 (diff) | |
download | wallabag-6e334aba689f891a229c8a57f908f10dad5b3759.tar.gz wallabag-6e334aba689f891a229c8a57f908f10dad5b3759.tar.zst wallabag-6e334aba689f891a229c8a57f908f10dad5b3759.zip |
for GET /api/entries, star, delete and archive status are no more necessary
3 files changed, 16 insertions, 11 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php index 513a6c11..07931f58 100644 --- a/src/Wallabag/CoreBundle/Controller/StaticController.php +++ b/src/Wallabag/CoreBundle/Controller/StaticController.php | |||
@@ -18,7 +18,6 @@ class StaticController extends Controller | |||
18 | ); | 18 | ); |
19 | } | 19 | } |
20 | 20 | ||
21 | |||
22 | /** | 21 | /** |
23 | * @Route("/", name="homepage") | 22 | * @Route("/", name="homepage") |
24 | */ | 23 | */ |
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index fc13b1a8..5f56e0fc 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php | |||
@@ -33,9 +33,9 @@ class WallabagRestController extends Controller | |||
33 | { | 33 | { |
34 | // TODO isArchived, isStarred et isDeleted ne doivent pas avoir de valeur par défaut | 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. | 35 | // TODO Si on ne passe rien, on ne filtre pas sur le statut. |
36 | $isArchived = $request->query->get('archive', 0); | 36 | $isArchived = $request->query->get('archive'); |
37 | $isStarred = $request->query->get('star', 0); | 37 | $isStarred = $request->query->get('star'); |
38 | $isDeleted = $request->query->get('delete', 0); | 38 | $isDeleted = $request->query->get('delete'); |
39 | $sort = $request->query->get('sort', 'created'); | 39 | $sort = $request->query->get('sort', 'created'); |
40 | $order = $request->query->get('order', 'desc'); | 40 | $order = $request->query->get('order', 'desc'); |
41 | $page = $request->query->get('page', 1); | 41 | $page = $request->query->get('page', 1); |
@@ -45,7 +45,7 @@ class WallabagRestController extends Controller | |||
45 | $entries = $this | 45 | $entries = $this |
46 | ->getDoctrine() | 46 | ->getDoctrine() |
47 | ->getRepository('WallabagCoreBundle:Entries') | 47 | ->getRepository('WallabagCoreBundle:Entries') |
48 | ->findEntries(1, (int) $isArchived, (int) $isStarred, (int) $isDeleted, $sort, $order); | 48 | ->findEntries(1, $isArchived, $isStarred, $isDeleted, $sort, $order); |
49 | 49 | ||
50 | if (!is_array($entries)) { | 50 | if (!is_array($entries)) { |
51 | throw $this->createNotFoundException(); | 51 | throw $this->createNotFoundException(); |
diff --git a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php index c76b4215..aaca4251 100644 --- a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php | |||
@@ -86,13 +86,19 @@ 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.isFav =:isStarred')->setParameter('isStarred', $isStarred) | 89 | ->where('e.userId =:userId')->setParameter('userId', $userId) |
90 | ->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived) | 90 | ->andWhere('e.isDeleted=0'); |
91 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 91 | |
92 | ->andWhere('e.isDeleted=0') | 92 | if (!is_null($isArchived)) { |
93 | $qb->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived); | ||
94 | } | ||
95 | |||
96 | if (!is_null($isStarred)) { | ||
97 | $qb->andWhere('e.isFav =:isStarred')->setParameter('isStarred', $isStarred); | ||
98 | } | ||
99 | |||
100 | return $qb | ||
93 | ->getQuery() | 101 | ->getQuery() |
94 | ->getResult(Query::HYDRATE_ARRAY); | 102 | ->getResult(Query::HYDRATE_ARRAY); |
95 | |||
96 | return $qb; | ||
97 | } | 103 | } |
98 | } | 104 | } |