aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-11-02 07:10:23 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-11-02 07:10:23 +0100
commit7816eb622df2353cea0ede0a3674d5eb3a01a1a9 (patch)
treeff4b67da5c88c26e2048d0665522b3e070272e03 /src/Wallabag/ApiBundle/Controller
parente0597476d1d5f6a4a7d6ea9b76966465f3d22fb8 (diff)
downloadwallabag-7816eb622df2353cea0ede0a3674d5eb3a01a1a9.tar.gz
wallabag-7816eb622df2353cea0ede0a3674d5eb3a01a1a9.tar.zst
wallabag-7816eb622df2353cea0ede0a3674d5eb3a01a1a9.zip
Add entry.saved event to import & rest
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller')
-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();