]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ApiBundle/Controller/WallabagRestController.php
Convert array + phpDoc
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / WallabagRestController.php
index d0a35013850c3794c6582205fd0befc5b1c46620..316d45be606b456acfc91d059e09ca9a5d25eb41 100644 (file)
@@ -43,8 +43,8 @@ class WallabagRestController extends FOSRestController
     {
         $this->validateAuthentication();
 
-        $isArchived = (int) $request->query->get('archive');
-        $isStarred = (int) $request->query->get('starred');
+        $isArchived = (null === $request->query->get('archive')) ? null : (bool) $request->query->get('archive');
+        $isStarred = (null === $request->query->get('starred')) ? null : (bool) $request->query->get('starred');
         $sort = $request->query->get('sort', 'created');
         $order = $request->query->get('order', 'desc');
         $page = (int) $request->query->get('page', 1);
@@ -52,7 +52,7 @@ class WallabagRestController extends FOSRestController
 
         $pager = $this->getDoctrine()
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findEntries($this->getUser()->getId(), (bool) $isArchived, (bool) $isStarred, $sort, $order);
+            ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order);
 
         $pager->setCurrentPage($page);
         $pager->setMaxPerPage($perPage);
@@ -126,12 +126,12 @@ class WallabagRestController extends FOSRestController
             $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
         }
 
-        if (true === (bool) $isStarred) {
-            $entry->setStarred(true);
+        if (!is_null($isStarred)) {
+            $entry->setStarred((bool) $isStarred);
         }
 
-        if (true === (bool) $isArchived) {
-            $entry->setArchived(true);
+        if (!is_null($isArchived)) {
+            $entry->setArchived((bool) $isArchived);
         }
 
         $em = $this->getDoctrine()->getManager();
@@ -384,6 +384,6 @@ class WallabagRestController extends FOSRestController
      */
     private function renderJsonResponse($json)
     {
-        return new Response($json, 200, array('application/json'));
+        return new Response($json, 200, ['application/json']);
     }
 }