aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/WallabagRestController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
index db9cf1be..e59ad4b7 100644
--- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
@@ -213,8 +213,34 @@ class WallabagRestController extends Controller
213 * } 213 * }
214 * ) 214 * )
215 */ 215 */
216 public function postEntriesTagsAction(Entry $entry) 216 public function postEntriesTagsAction(Request $request, Entry $entry)
217 { 217 {
218 $tags = explode(',', $request->request->get('tags'));
219
220 foreach ($tags as $label) {
221 $tagEntity = $this
222 ->getDoctrine()
223 ->getRepository('WallabagCoreBundle:Tag')
224 ->findOneByLabel($label);
225
226 if (is_null($tagEntity)) {
227 $tagEntity = new Tag();
228 $tagEntity->setLabel($label);
229 }
230
231 // only add the tag on the entry if the relation doesn't exist
232 if (!$entry->getTags()->contains($tagEntity)) {
233 $entry->addTag($tagEntity);
234 }
235 }
236
237 $em = $this->getDoctrine()->getManager();
238 $em->persist($entry);
239 $em->flush();
240
241 $json = $this->get('serializer')->serialize($entry, 'json');
242
243 return new Response($json, 200, array('application/json'));
218 } 244 }
219 245
220 /** 246 /**