aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2016-11-03 16:22:07 +0100
committerGitHub <noreply@github.com>2016-11-03 16:22:07 +0100
commitda4136557963018287cae61226e9006c3c741747 (patch)
tree6bf23c0d32f3780843798ae47c65377ae1ff961a /src/Wallabag/ApiBundle/Controller/WallabagRestController.php
parent816c0940d142f8ec69bdd3f302c9751033cce7e2 (diff)
parentca08d02f2f17c0e4ec0152a701c540f62713a428 (diff)
downloadwallabag-da4136557963018287cae61226e9006c3c741747.tar.gz
wallabag-da4136557963018287cae61226e9006c3c741747.tar.zst
wallabag-da4136557963018287cae61226e9006c3c741747.zip
Merge pull request #2180 from wallabag/download-pictures
Download pictures
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();