use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\AnnotationBundle\Entity\Annotation;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Wallabag\CoreBundle\Event\EntrySavedEvent;
+use Wallabag\CoreBundle\Event\EntryDeletedEvent;
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);
$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();
{
$this->validateAuthentication();
- return $this->forward('WallabagApiBundle:WallabagRest:getAnnotations', [
+ return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:getAnnotations', [
'entry' => $entry,
]);
}
/**
* Creates a new annotation.
*
- * @param Request $request
- * @param Entry $entry
- *
- * @return JsonResponse
* @ApiDoc(
* requirements={
* {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
* {"name"="text", "dataType"="string", "required"=true, "description"=""},
* }
* )
+ *
+ * @param Request $request
+ * @param Entry $entry
+ *
+ * @return JsonResponse
*/
public function postAnnotationAction(Request $request, Entry $entry)
{
$this->validateAuthentication();
- return $this->forward('WallabagApiBundle:WallabagRest:postAnnotation', [
- 'request' => $request,
- 'entry' => $entry,
- ]);
+ return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:postAnnotation', [
+ 'request' => $request,
+ 'entry' => $entry,
+ ]);
}
/**
{
$this->validateAuthentication();
- return $this->forward('WallabagApiBundle:WallabagRest:putAnnotation', [
- 'annotation' => $annotation,
- 'request' => $request,
- ]);
+ return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:putAnnotation', [
+ 'annotation' => $annotation,
+ 'request' => $request,
+ ]);
}
/**
{
$this->validateAuthentication();
- return $this->forward('WallabagApiBundle:WallabagRest:deleteAnnotation', [
- 'annotation' => $annotation,
- ]);
+ return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:deleteAnnotation', [
+ 'annotation' => $annotation,
+ ]);
}
/**