aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorJeremy <j0k3r@users.noreply.github.com>2015-02-05 21:51:05 +0100
committerJeremy <j0k3r@users.noreply.github.com>2015-02-05 21:51:05 +0100
commitc8dee953961964aa842e516995f0c6fafd007f9b (patch)
tree8a97d887bba874f248be86626b1205087ff54aa0 /src/Wallabag/CoreBundle
parent93e28e4d2ec677a852d71d167dc7c54ef2780cae (diff)
parentc0284f6182a7421d2352e9288205d70b81185a7d (diff)
downloadwallabag-c8dee953961964aa842e516995f0c6fafd007f9b.tar.gz
wallabag-c8dee953961964aa842e516995f0c6fafd007f9b.tar.zst
wallabag-c8dee953961964aa842e516995f0c6fafd007f9b.zip
Merge pull request #1055 from wallabag/v2-api-patch-methid
PATCH method, boolean for some parameters and change entity methods name
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php41
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entries.php12
2 files changed, 39 insertions, 14 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
index abbf5437..f14f821b 100644
--- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
@@ -17,9 +17,9 @@ class WallabagRestController extends Controller
17 * 17 *
18 * @ApiDoc( 18 * @ApiDoc(
19 * parameters={ 19 * parameters={
20 * {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', all entries by default", "description"="filter by archived status."}, 20 * {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false, all entries by default", "description"="filter by archived status."},
21 * {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', all entries by default", "description"="filter by starred status."}, 21 * {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false, all entries by default", "description"="filter by starred status."},
22 * {"name"="delete", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by deleted status."}, 22 * {"name"="delete", "dataType"="boolean", "required"=false, "format"="true or false, default '0'", "description"="filter by deleted status."},
23 * {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."}, 23 * {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."},
24 * {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."}, 24 * {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."},
25 * {"name"="page", "dataType"="integer", "required"=false, "format"="default '1'", "description"="what page you want."}, 25 * {"name"="page", "dataType"="integer", "required"=false, "format"="default '1'", "description"="what page you want."},
@@ -106,14 +106,40 @@ class WallabagRestController extends Controller
106 * parameters={ 106 * parameters={
107 * {"name"="title", "dataType"="string", "required"=false}, 107 * {"name"="title", "dataType"="string", "required"=false},
108 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."}, 108 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
109 * {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="archived the entry."}, 109 * {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false", "description"="archived the entry."},
110 * {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="starred the entry."}, 110 * {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false", "description"="starred the entry."},
111 * {"name"="delete", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="flag as deleted. Default false. In case that you don't want to *really* remove it.."}, 111 * {"name"="delete", "dataType"="boolean", "required"=false, "format"="true or false", "description"="flag as deleted. Default false. In case that you don't want to *really* remove it.."},
112 * } 112 * }
113 * ) 113 * )
114 */ 114 */
115 public function patchEntriesAction(Entries $entry) 115 public function patchEntriesAction(Entries $entry, Request $request)
116 { 116 {
117 $title = $request->request->get("title");
118 $tags = $request->request->get("tags", array());
119 $isArchived = $request->request->get("archive");
120 $isDeleted = $request->request->get("delete");
121 $isStarred = $request->request->get("star");
122
123 if (!is_null($title)) {
124 $entry->setTitle($title);
125 }
126
127 if (!is_null($isArchived)) {
128 $entry->setRead($isArchived);
129 }
130
131 if (!is_null($isDeleted)) {
132 $entry->setDeleted($isDeleted);
133 }
134
135 if (!is_null($isStarred)) {
136 $entry->setFav($isStarred);
137 }
138
139 $em = $this->getDoctrine()->getManager();
140 $em->flush();
141
142 return $entry;
117 } 143 }
118 144
119 /** 145 /**
@@ -133,7 +159,6 @@ class WallabagRestController extends Controller
133 159
134 $em = $this->getDoctrine()->getManager(); 160 $em = $this->getDoctrine()->getManager();
135 $entry->setDeleted(1); 161 $entry->setDeleted(1);
136 $em->persist($entry);
137 $em->flush(); 162 $em->flush();
138 163
139 return $entry; 164 return $entry;
diff --git a/src/Wallabag/CoreBundle/Entity/Entries.php b/src/Wallabag/CoreBundle/Entity/Entries.php
index 6eb1efc0..ab5b859b 100644
--- a/src/Wallabag/CoreBundle/Entity/Entries.php
+++ b/src/Wallabag/CoreBundle/Entity/Entries.php
@@ -185,7 +185,7 @@ class Entries
185 * @param string $isRead 185 * @param string $isRead
186 * @return Entries 186 * @return Entries
187 */ 187 */
188 public function setIsRead($isRead) 188 public function setRead($isRead)
189 { 189 {
190 $this->isRead = $isRead; 190 $this->isRead = $isRead;
191 191
@@ -197,7 +197,7 @@ class Entries
197 * 197 *
198 * @return string 198 * @return string
199 */ 199 */
200 public function getIsRead() 200 public function isRead()
201 { 201 {
202 return $this->isRead; 202 return $this->isRead;
203 } 203 }
@@ -215,7 +215,7 @@ class Entries
215 * @param string $isFav 215 * @param string $isFav
216 * @return Entries 216 * @return Entries
217 */ 217 */
218 public function setIsFav($isFav) 218 public function setFav($isFav)
219 { 219 {
220 $this->isFav = $isFav; 220 $this->isFav = $isFav;
221 221
@@ -227,7 +227,7 @@ class Entries
227 * 227 *
228 * @return string 228 * @return string
229 */ 229 */
230 public function getIsFav() 230 public function isFav()
231 { 231 {
232 return $this->isFav; 232 return $this->isFav;
233 } 233 }
@@ -402,7 +402,7 @@ class Entries
402 /** 402 /**
403 * @return boolean 403 * @return boolean
404 */ 404 */
405 public function isIsPublic() 405 public function isPublic()
406 { 406 {
407 return $this->isPublic; 407 return $this->isPublic;
408 } 408 }
@@ -410,7 +410,7 @@ class Entries
410 /** 410 /**
411 * @param boolean $isPublic 411 * @param boolean $isPublic
412 */ 412 */
413 public function setIsPublic($isPublic) 413 public function setPublic($isPublic)
414 { 414 {
415 $this->isPublic = $isPublic; 415 $this->isPublic = $isPublic;
416 } 416 }