3 namespace WallabagBundle\Controller
;
5 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
6 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
7 use Symfony\Component\HttpFoundation\Request
;
8 use WallabagBundle\Repository
;
9 use WallabagBundle\Entity\Entries
;
11 class EntryController
extends Controller
14 * Shows unread entries for current user
16 * @Route("/unread", name="unread")
17 * @return \Symfony\Component\HttpFoundation\Response
19 public function showUnreadAction()
21 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
22 $entries = $repository->findUnreadByUser(1, 0);
25 'WallabagBundle:Entry:entries.html.twig',
26 array('entries' => $entries)
31 * Shows read entries for current user
33 * @Route("/archive", name="archive")
34 * @return \Symfony\Component\HttpFoundation\Response
36 public function showArchiveAction()
38 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
39 $entries = $repository->findArchiveByUser(1, 0);
42 'WallabagBundle:Entry:entries.html.twig',
43 array('entries' => $entries)
48 * Shows starred entries for current user
50 * @Route("/starred", name="starred")
51 * @return \Symfony\Component\HttpFoundation\Response
53 public function showStarredAction()
55 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
56 $entries = $repository->findStarredByUser(1, 0);
59 'WallabagBundle:Entry:entries.html.twig',
60 array('entries' => $entries)
67 * @param Entries $entry
68 * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
69 * @return \Symfony\Component\HttpFoundation\Response
71 public function viewAction(Entries
$entry)
74 'WallabagBundle:Entry:entry.html.twig',
75 array('entry' => $entry)
80 * Changes read status for an entry
82 * @param Request $request
83 * @param Entries $entry
84 * @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry")
85 * @return \Symfony\Component\HttpFoundation\RedirectResponse
87 public function toggleArchiveAction(Request
$request, Entries
$entry)
89 $entry->toggleArchive();
90 $this->getDoctrine()->getManager()->flush();
92 $this->get('session')->getFlashBag()->add(
97 return $this->redirect($request->headers
->get('referer'));
101 * Changes favorite status for an entry
103 * @param Request $request
104 * @param Entries $entry
105 * @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry")
106 * @return \Symfony\Component\HttpFoundation\RedirectResponse
108 public function toggleStarAction(Request
$request, Entries
$entry)
110 $entry->toggleStar();
111 $this->getDoctrine()->getManager()->flush();
113 $this->get('session')->getFlashBag()->add(
118 return $this->redirect($request->headers
->get('referer'));
124 * @param Request $request
125 * @param Entries $entry
126 * @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry")
127 * @return \Symfony\Component\HttpFoundation\RedirectResponse
129 public function deleteEntryAction(Request
$request, Entries
$entry)
131 $em = $this->getDoctrine()->getEntityManager();
135 $this->get('session')->getFlashBag()->add(
140 return $this->redirect($request->headers
->get('referer'));