From 6079aaa33dc78772e497725d7247c371b80b5578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 4 Feb 2015 18:12:13 +0100 Subject: change delete status for GET /api/entries method --- src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 8 +++----- src/Wallabag/CoreBundle/Repository/EntriesRepository.php | 7 +++++-- 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 * * @ApiDoc( * parameters={ - * {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by archived status."}, - * {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by starred status."}, + * {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', all entries by default", "description"="filter by archived status."}, + * {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', all entries by default", "description"="filter by starred status."}, * {"name"="delete", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by deleted status."}, * {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."}, * {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."}, @@ -31,11 +31,9 @@ class WallabagRestController extends Controller */ public function getEntriesAction(Request $request) { - // TODO isArchived, isStarred et isDeleted ne doivent pas avoir de valeur par défaut - // TODO Si on ne passe rien, on ne filtre pas sur le statut. $isArchived = $request->query->get('archive'); $isStarred = $request->query->get('star'); - $isDeleted = $request->query->get('delete'); + $isDeleted = $request->query->get('delete', 0); $sort = $request->query->get('sort', 'created'); $order = $request->query->get('order', 'desc'); $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 //TODO tous les paramètres ne sont pas utilisés, à corriger $qb = $this->createQueryBuilder('e') ->select('e') - ->where('e.userId =:userId')->setParameter('userId', $userId) - ->andWhere('e.isDeleted=0'); + ->where('e.userId =:userId')->setParameter('userId', $userId); if (!is_null($isArchived)) { $qb->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived); @@ -97,6 +96,10 @@ class EntriesRepository extends EntityRepository $qb->andWhere('e.isFav =:isStarred')->setParameter('isStarred', $isStarred); } + if (!is_null($isDeleted)) { + $qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', $isDeleted); + } + return $qb ->getQuery() ->getResult(Query::HYDRATE_ARRAY); -- cgit v1.2.3