From: Nicolas Lœuillet Date: Wed, 4 Feb 2015 17:06:42 +0000 (+0100) Subject: for GET /api/entries, star, delete and archive status are no more necessary X-Git-Tag: 2.0.0-alpha.0~104 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=6e334aba689f891a229c8a57f908f10dad5b3759;p=github%2Fwallabag%2Fwallabag.git for GET /api/entries, star, delete and archive status are no more necessary --- 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; } }