]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Controller/NotificationsController.php
changes and default actions
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / NotificationsController.php
CommitLineData
22a4b20e
TC
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response;
4fa9470f 9use Wallabag\CoreBundle\Entity\Notification;
22a4b20e
TC
10
11class NotificationsController extends Controller
12{
13 /**
14 * @param Request $request
15 *
16 * @Route("/notifications", name="notifications-all")
17 *
18 * @return \Symfony\Component\HttpFoundation\Response
19 */
20 public function getAllNotificationsAction(Request $request)
21 {
22 $notifications = $this->getDoctrine()->getRepository('WallabagCoreBundle:Notification')->findByUser($this->getUser());
23
24 return $this->render('WallabagCoreBundle:Notification:notifications.html.twig', ['notifications' => $notifications]);
25 }
26
27 /**
28 * @Route("/notifications/readall", name="notification-archive-all")
29 *
30 * @param Request $request
31 * @return Response
32 */
33 public function markAllNotificationsAsReadAction(Request $request)
34 {
35 $this->getDoctrine()->getRepository('WallabagCoreBundle:Notification')->markAllAsReadForUser($this->getUser()->getId());
36
37 return $this->redirectToRoute('notifications-all');
38 }
4fa9470f
TC
39
40 /**
41 * @Route("/notifications/read/{notification}", name="notification-archive")
42 *
43 * @param Notification $notification
44 * @return Response
45 */
46 public function markNotificationsAsReadAction(Notification $notification)
47 {
48 $em = $this->getDoctrine()->getManager();
49
50 $notification->setRead(true);
51
52 $em->persist($notification);
53 $em->flush();
54
55 return $this->redirectToRoute('notifications-all');
56 }
22a4b20e 57}