]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ApiBundle/Controller/WallabagRestController.php
add more properties for entries #1634
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / WallabagRestController.php
index 03990088218971850a9c87240381e911c3a1a2e0..ad85a1779a7c459c43b5d94fd7821138e98528c1 100644 (file)
@@ -97,6 +97,9 @@ class WallabagRestController extends FOSRestController
      *          {"name"="url", "dataType"="string", "required"=true, "format"="http://www.test.com/article.html", "description"="Url for the entry."},
      *          {"name"="title", "dataType"="string", "required"=false, "description"="Optional, we'll get the title from the page."},
      *          {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
+     *          {"name"="starred", "dataType"="boolean", "required"=false, "format"="true or false", "description"="entry already starred"},
+     *          {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false", "description"="entry already archived"},
+     *          {"name"="content", "dataType"="string", "required"=false, "format"="content", "description"="content you want to pass directly"},
      *       }
      * )
      *
@@ -107,6 +110,9 @@ class WallabagRestController extends FOSRestController
         $this->validateAuthentication();
 
         $url = $request->request->get('url');
+        $content = $request->request->get('content');
+        $isArchived = $request->request->get('archive');
+        $isStarred = $request->request->get('starred');
 
         $entry = $this->get('wallabag_core.content_proxy')->updateEntry(
             new Entry($this->getUser()),
@@ -118,8 +124,21 @@ class WallabagRestController extends FOSRestController
             $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
         }
 
+        if (!empty($isStarred)) {
+            $entry->setStarred($isStarred);
+        }
+
+        if (!empty($isArchived)) {
+            $entry->setArchived($isArchived);
+        }
+
+        if (!empty($content)) {
+            $entry->setContent($content);
+        }
+
         $em = $this->getDoctrine()->getManager();
         $em->persist($entry);
+
         $em->flush();
 
         $json = $this->get('serializer')->serialize($entry, 'json');