From 6e334aba689f891a229c8a57f908f10dad5b3759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 4 Feb 2015 18:06:42 +0100 Subject: for GET /api/entries, star, delete and archive status are no more necessary --- .../CoreBundle/Controller/StaticController.php | 1 - .../CoreBundle/Controller/WallabagRestController.php | 8 ++++---- .../CoreBundle/Repository/EntriesRepository.php | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src') 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 ); } - /** * @Route("/", name="homepage") */ 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 { // 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', 0); - $isStarred = $request->query->get('star', 0); - $isDeleted = $request->query->get('delete', 0); + $isArchived = $request->query->get('archive'); + $isStarred = $request->query->get('star'); + $isDeleted = $request->query->get('delete'); $sort = $request->query->get('sort', 'created'); $order = $request->query->get('order', 'desc'); $page = $request->query->get('page', 1); @@ -45,7 +45,7 @@ class WallabagRestController extends Controller $entries = $this ->getDoctrine() ->getRepository('WallabagCoreBundle:Entries') - ->findEntries(1, (int) $isArchived, (int) $isStarred, (int) $isDeleted, $sort, $order); + ->findEntries(1, $isArchived, $isStarred, $isDeleted, $sort, $order); if (!is_array($entries)) { 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 //TODO tous les paramètres ne sont pas utilisés, à corriger $qb = $this->createQueryBuilder('e') ->select('e') - ->where('e.isFav =:isStarred')->setParameter('isStarred', $isStarred) - ->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived) - ->andWhere('e.userId =:userId')->setParameter('userId', $userId) - ->andWhere('e.isDeleted=0') + ->where('e.userId =:userId')->setParameter('userId', $userId) + ->andWhere('e.isDeleted=0'); + + if (!is_null($isArchived)) { + $qb->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived); + } + + if (!is_null($isStarred)) { + $qb->andWhere('e.isFav =:isStarred')->setParameter('isStarred', $isStarred); + } + + return $qb ->getQuery() ->getResult(Query::HYDRATE_ARRAY); - - return $qb; } } -- cgit v1.2.3