diff options
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 9 |
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; | |||
14 | use Wallabag\CoreBundle\Entity\Entry; | 14 | use Wallabag\CoreBundle\Entity\Entry; |
15 | use Wallabag\CoreBundle\Entity\Tag; | 15 | use Wallabag\CoreBundle\Entity\Tag; |
16 | use Wallabag\AnnotationBundle\Entity\Annotation; | 16 | use Wallabag\AnnotationBundle\Entity\Annotation; |
17 | use Wallabag\CoreBundle\Event\EntrySavedEvent; | ||
18 | use Wallabag\CoreBundle\Event\EntryDeletedEvent; | ||
17 | 19 | ||
18 | class WallabagRestController extends FOSRestController | 20 | class 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(); |