aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
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 /src/Wallabag/CoreBundle/Controller
parentc2e2906c8dcb83494c34d22c57f262d8f2b5f58d (diff)
downloadwallabag-2c093b03de92fb050a50cd4db183ba55abd4ff84.tar.gz
wallabag-2c093b03de92fb050a50cd4db183ba55abd4ff84.tar.zst
wallabag-2c093b03de92fb050a50cd4db183ba55abd4ff84.zip
PATCH method, boolean for some parameters and change entity methods name
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php41
1 files changed, 34 insertions, 7 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 /**