From 816ad4051baa401e46b42121e6813345a8030032 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 8 Feb 2016 22:00:38 +0100 Subject: add more properties for entries #1634 --- .../ApiBundle/Controller/WallabagRestController.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/Wallabag/ApiBundle/Controller/WallabagRestController.php') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 03990088..ad85a177 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -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'); -- cgit v1.2.3 From 11a452813c5c048174f0d827c2a171bb53520d0a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 9 Feb 2016 14:18:55 +0100 Subject: use booleans instead of empty --- src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/ApiBundle/Controller/WallabagRestController.php') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index ad85a177..28145e45 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -124,12 +124,12 @@ class WallabagRestController extends FOSRestController $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags); } - if (!empty($isStarred)) { - $entry->setStarred($isStarred); + if (true === (bool) $isStarred) { + $entry->setStarred(true); } - if (!empty($isArchived)) { - $entry->setArchived($isArchived); + if (true === (bool) $isArchived) { + $entry->setArchived(true); } if (!empty($content)) { -- cgit v1.2.3 From fba9e7d44d5987a603add50dc450f50079340dcc Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 4 Mar 2016 11:40:48 +0100 Subject: Remove 'content' from API Waiting to find a good solution to avoid side problem since user can no define the content --- src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/Wallabag/ApiBundle/Controller/WallabagRestController.php') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 28145e45..35a90edd 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -99,7 +99,6 @@ class WallabagRestController extends FOSRestController * {"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"}, * } * ) * @@ -110,7 +109,6 @@ 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'); @@ -132,10 +130,6 @@ class WallabagRestController extends FOSRestController $entry->setArchived(true); } - if (!empty($content)) { - $entry->setContent($content); - } - $em = $this->getDoctrine()->getManager(); $em->persist($entry); -- cgit v1.2.3