forked from wallabag/wallabag
Add entry.saved event to import & rest
This commit is contained in:
@ -14,6 +14,8 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
use Wallabag\AnnotationBundle\Entity\Annotation;
|
||||
use Wallabag\CoreBundle\Event\EntrySavedEvent;
|
||||
use Wallabag\CoreBundle\Event\EntryDeletedEvent;
|
||||
|
||||
class WallabagRestController extends FOSRestController
|
||||
{
|
||||
@ -233,9 +235,11 @@ class WallabagRestController extends FOSRestController
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($entry);
|
||||
|
||||
$em->flush();
|
||||
|
||||
// entry saved, dispatch event about it!
|
||||
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
||||
|
||||
$json = $this->get('serializer')->serialize($entry, 'json');
|
||||
|
||||
return (new JsonResponse())->setJson($json);
|
||||
@ -308,6 +312,9 @@ class WallabagRestController extends FOSRestController
|
||||
$this->validateAuthentication();
|
||||
$this->validateUserAccess($entry->getUser()->getId());
|
||||
|
||||
// entry deleted, dispatch event about it!
|
||||
$this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($entry);
|
||||
$em->flush();
|
||||
|
||||
Reference in New Issue
Block a user