aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller/WallabagRestController.php')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index a73d44ca..50652b77 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -14,6 +14,8 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
14use Wallabag\CoreBundle\Entity\Entry; 14use Wallabag\CoreBundle\Entity\Entry;
15use Wallabag\CoreBundle\Entity\Tag; 15use Wallabag\CoreBundle\Entity\Tag;
16use Wallabag\AnnotationBundle\Entity\Annotation; 16use Wallabag\AnnotationBundle\Entity\Annotation;
17use Wallabag\CoreBundle\Event\EntrySavedEvent;
18use Wallabag\CoreBundle\Event\EntryDeletedEvent;
17 19
18class WallabagRestController extends FOSRestController 20class WallabagRestController extends FOSRestController
19{ 21{
@@ -233,9 +235,11 @@ class WallabagRestController extends FOSRestController
233 235
234 $em = $this->getDoctrine()->getManager(); 236 $em = $this->getDoctrine()->getManager();
235 $em->persist($entry); 237 $em->persist($entry);
236
237 $em->flush(); 238 $em->flush();
238 239
240 // entry saved, dispatch event about it!
241 $this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
242
239 $json = $this->get('serializer')->serialize($entry, 'json'); 243 $json = $this->get('serializer')->serialize($entry, 'json');
240 244
241 return (new JsonResponse())->setJson($json); 245 return (new JsonResponse())->setJson($json);
@@ -308,6 +312,9 @@ class WallabagRestController extends FOSRestController
308 $this->validateAuthentication(); 312 $this->validateAuthentication();
309 $this->validateUserAccess($entry->getUser()->getId()); 313 $this->validateUserAccess($entry->getUser()->getId());
310 314
315 // entry deleted, dispatch event about it!
316 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
317
311 $em = $this->getDoctrine()->getManager(); 318 $em = $this->getDoctrine()->getManager();
312 $em->remove($entry); 319 $em->remove($entry);
313 $em->flush(); 320 $em->flush();