aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-02-05 18:21:31 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-02-05 18:21:31 +0100
commit2c093b03de92fb050a50cd4db183ba55abd4ff84 (patch)
tree030dee7cfe7c330d361a81557673823199296478
parentc2e2906c8dcb83494c34d22c57f262d8f2b5f58d (diff)
downloadwallabag-2c093b03de92fb050a50cd4db183ba55abd4ff84.tar.gz
wallabag-2c093b03de92fb050a50cd4db183ba55abd4ff84.tar.zst
wallabag-2c093b03de92fb050a50cd4db183ba55abd4ff84.zip
PATCH method, boolean for some parameters and change entity methods name
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php41
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entries.php12
2 files changed, 40 insertions, 13 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
index 55906ce0..711e7bb2 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."},
@@ -109,14 +109,41 @@ class WallabagRestController extends Controller
109 * parameters={ 109 * parameters={
110 * {"name"="title", "dataType"="string", "required"=false}, 110 * {"name"="title", "dataType"="string", "required"=false},
111 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."}, 111 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
112 * {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="archived the entry."}, 112 * {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false", "description"="archived the entry."},
113 * {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="starred the entry."}, 113 * {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false", "description"="starred the entry."},
114 * {"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.."}, 114 * {"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.."},
115 * } 115 * }
116 * ) 116 * )
117 */ 117 */
118 public function patchEntriesAction(Entries $entry) 118 public function patchEntriesAction(Entries $entry, Request $request)
119 { 119 {
120 $title = $request->request->get("title");
121 $tags = $request->request->get("tags", array());
122 $isArchived = $request->request->get("archive");
123 $isDeleted = $request->request->get("delete");
124 $isStarred = $request->request->get("star");
125
126 if (!is_null($title)) {
127 $entry->setTitle($title);
128 }
129
130 if (!is_null($isArchived)) {
131 $entry->setRead($isArchived);
132 }
133
134 if (!is_null($isDeleted)) {
135 $entry->setDeleted($isDeleted);
136 }
137
138 if (!is_null($isStarred)) {
139 $entry->setFav($isStarred);
140 }
141
142 $em = $this->getDoctrine()->getManager();
143 $em->persist($entry);
144 $em->flush();
145
146 return $entry;
120 } 147 }
121 148
122 /** 149 /**
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 }