aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller/EntryRestController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller/EntryRestController.php')
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 24fa7b3b..b3622c62 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -10,6 +10,8 @@ use Symfony\Component\HttpFoundation\JsonResponse;
10use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 10use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
11use Wallabag\CoreBundle\Entity\Entry; 11use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Entity\Tag; 12use Wallabag\CoreBundle\Entity\Tag;
13use Wallabag\CoreBundle\Event\EntrySavedEvent;
14use Wallabag\CoreBundle\Event\EntryDeletedEvent;
13 15
14class EntryRestController extends WallabagRestController 16class EntryRestController extends WallabagRestController
15{ 17{
@@ -200,9 +202,11 @@ class EntryRestController extends WallabagRestController
200 202
201 $em = $this->getDoctrine()->getManager(); 203 $em = $this->getDoctrine()->getManager();
202 $em->persist($entry); 204 $em->persist($entry);
203
204 $em->flush(); 205 $em->flush();
205 206
207 // entry saved, dispatch event about it!
208 $this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
209
206 $json = $this->get('serializer')->serialize($entry, 'json'); 210 $json = $this->get('serializer')->serialize($entry, 'json');
207 211
208 return (new JsonResponse())->setJson($json); 212 return (new JsonResponse())->setJson($json);
@@ -279,6 +283,9 @@ class EntryRestController extends WallabagRestController
279 $em->remove($entry); 283 $em->remove($entry);
280 $em->flush(); 284 $em->flush();
281 285
286 // entry deleted, dispatch event about it!
287 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
288
282 $json = $this->get('serializer')->serialize($entry, 'json'); 289 $json = $this->get('serializer')->serialize($entry, 'json');
283 290
284 return (new JsonResponse())->setJson($json); 291 return (new JsonResponse())->setJson($json);