aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 2633a311..744e1a60 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -27,13 +27,13 @@ class WallabagRestController extends FOSRestController
27 * 27 *
28 * @ApiDoc( 28 * @ApiDoc(
29 * parameters={ 29 * parameters={
30 * {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false, all entries by default", "description"="filter by archived status."}, 30 * {"name"="archive", "dataType"="integer", "required"=false, "format"="1 or 0, all entries by default", "description"="filter by archived status."},
31 * {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false, all entries by default", "description"="filter by starred status."}, 31 * {"name"="starred", "dataType"="integer", "required"=false, "format"="1 or 0, all entries by default", "description"="filter by starred status."},
32 * {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."}, 32 * {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."},
33 * {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."}, 33 * {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."},
34 * {"name"="page", "dataType"="integer", "required"=false, "format"="default '1'", "description"="what page you want."}, 34 * {"name"="page", "dataType"="integer", "required"=false, "format"="default '1'", "description"="what page you want."},
35 * {"name"="perPage", "dataType"="integer", "required"=false, "format"="default'30'", "description"="results per page."}, 35 * {"name"="perPage", "dataType"="integer", "required"=false, "format"="default'30'", "description"="results per page."},
36 * {"name"="tags", "dataType"="string", "required"=false, "format"="api%2Crest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."}, 36 * {"name"="tags", "dataType"="string", "required"=false, "format"="api,rest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."},
37 * } 37 * }
38 * ) 38 * )
39 * 39 *
@@ -43,8 +43,8 @@ class WallabagRestController extends FOSRestController
43 { 43 {
44 $this->validateAuthentication(); 44 $this->validateAuthentication();
45 45
46 $isArchived = $request->query->get('archive'); 46 $isArchived = (int) $request->query->get('archive');
47 $isStarred = $request->query->get('star'); 47 $isStarred = (int) $request->query->get('starred');
48 $sort = $request->query->get('sort', 'created'); 48 $sort = $request->query->get('sort', 'created');
49 $order = $request->query->get('order', 'desc'); 49 $order = $request->query->get('order', 'desc');
50 $page = (int) $request->query->get('page', 1); 50 $page = (int) $request->query->get('page', 1);
@@ -52,7 +52,7 @@ class WallabagRestController extends FOSRestController
52 52
53 $pager = $this->getDoctrine() 53 $pager = $this->getDoctrine()
54 ->getRepository('WallabagCoreBundle:Entry') 54 ->getRepository('WallabagCoreBundle:Entry')
55 ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order); 55 ->findEntries($this->getUser()->getId(), (bool) $isArchived, (bool) $isStarred, $sort, $order);
56 56
57 $pager->setCurrentPage($page); 57 $pager->setCurrentPage($page);
58 $pager->setMaxPerPage($perPage); 58 $pager->setMaxPerPage($perPage);
@@ -97,8 +97,8 @@ class WallabagRestController extends FOSRestController
97 * {"name"="url", "dataType"="string", "required"=true, "format"="http://www.test.com/article.html", "description"="Url for the entry."}, 97 * {"name"="url", "dataType"="string", "required"=true, "format"="http://www.test.com/article.html", "description"="Url for the entry."},
98 * {"name"="title", "dataType"="string", "required"=false, "description"="Optional, we'll get the title from the page."}, 98 * {"name"="title", "dataType"="string", "required"=false, "description"="Optional, we'll get the title from the page."},
99 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."}, 99 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
100 * {"name"="starred", "dataType"="boolean", "required"=false, "format"="true or false", "description"="entry already starred"}, 100 * {"name"="starred", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="entry already starred"},
101 * {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false", "description"="entry already archived"}, 101 * {"name"="archive", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="entry already archived"},
102 * } 102 * }
103 * ) 103 * )
104 * 104 *
@@ -109,8 +109,8 @@ class WallabagRestController extends FOSRestController
109 $this->validateAuthentication(); 109 $this->validateAuthentication();
110 110
111 $url = $request->request->get('url'); 111 $url = $request->request->get('url');
112 $isArchived = $request->request->get('archive'); 112 $isArchived = (int) $request->request->get('archive');
113 $isStarred = $request->request->get('starred'); 113 $isStarred = (int) $request->request->get('starred');
114 114
115 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId()); 115 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId());
116 116
@@ -126,12 +126,12 @@ class WallabagRestController extends FOSRestController
126 $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags); 126 $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
127 } 127 }
128 128
129 if (true === (bool) $isStarred) { 129 if (!is_null($isStarred)) {
130 $entry->setStarred(true); 130 $entry->setStarred((bool) $isStarred);
131 } 131 }
132 132
133 if (true === (bool) $isArchived) { 133 if (!is_null($isArchived)) {
134 $entry->setArchived(true); 134 $entry->setArchived((bool) $isArchived);
135 } 135 }
136 136
137 $em = $this->getDoctrine()->getManager(); 137 $em = $this->getDoctrine()->getManager();
@@ -154,8 +154,8 @@ class WallabagRestController extends FOSRestController
154 * parameters={ 154 * parameters={
155 * {"name"="title", "dataType"="string", "required"=false}, 155 * {"name"="title", "dataType"="string", "required"=false},
156 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."}, 156 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
157 * {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false", "description"="archived the entry."}, 157 * {"name"="archive", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="archived the entry."},
158 * {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false", "description"="starred the entry."}, 158 * {"name"="starred", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="starred the entry."},
159 * } 159 * }
160 * ) 160 * )
161 * 161 *
@@ -167,19 +167,19 @@ class WallabagRestController extends FOSRestController
167 $this->validateUserAccess($entry->getUser()->getId()); 167 $this->validateUserAccess($entry->getUser()->getId());
168 168
169 $title = $request->request->get('title'); 169 $title = $request->request->get('title');
170 $isArchived = $request->request->get('archive'); 170 $isArchived = (int) $request->request->get('archive');
171 $isStarred = $request->request->get('star'); 171 $isStarred = (int) $request->request->get('starred');
172 172
173 if (!is_null($title)) { 173 if (!is_null($title)) {
174 $entry->setTitle($title); 174 $entry->setTitle($title);
175 } 175 }
176 176
177 if (!is_null($isArchived)) { 177 if (!is_null($isArchived)) {
178 $entry->setArchived($isArchived); 178 $entry->setArchived((bool) $isArchived);
179 } 179 }
180 180
181 if (!is_null($isStarred)) { 181 if (!is_null($isStarred)) {
182 $entry->setStarred($isStarred); 182 $entry->setStarred((bool) $isStarred);
183 } 183 }
184 184
185 $tags = $request->request->get('tags', ''); 185 $tags = $request->request->get('tags', '');