aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/WallabagBundle/Controller/EntryController.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-01-23 12:45:24 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-01-23 12:45:24 +0100
commit163eae0bb15d0daa5390f434a42a8176eca186e7 (patch)
tree0e1ab2c2bb9591e826e73d875cbb04fdabb3f77f /src/WallabagBundle/Controller/EntryController.php
parentbd9f08157cc10619e9bb9dace6df43090dde44a9 (diff)
downloadwallabag-163eae0bb15d0daa5390f434a42a8176eca186e7.tar.gz
wallabag-163eae0bb15d0daa5390f434a42a8176eca186e7.tar.zst
wallabag-163eae0bb15d0daa5390f434a42a8176eca186e7.zip
toggle archive / fav actions
Diffstat (limited to 'src/WallabagBundle/Controller/EntryController.php')
-rw-r--r--src/WallabagBundle/Controller/EntryController.php92
1 files changed, 82 insertions, 10 deletions
diff --git a/src/WallabagBundle/Controller/EntryController.php b/src/WallabagBundle/Controller/EntryController.php
index 233a6c32..fbbb76aa 100644
--- a/src/WallabagBundle/Controller/EntryController.php
+++ b/src/WallabagBundle/Controller/EntryController.php
@@ -4,67 +4,139 @@ namespace WallabagBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request;
7use WallabagBundle\Repository; 8use WallabagBundle\Repository;
9use WallabagBundle\Entity\Entries;
8 10
9class EntryController extends Controller 11class EntryController extends Controller
10{ 12{
11 /** 13 /**
14 * Shows unread entries for current user
15 *
12 * @Route("/unread", name="unread") 16 * @Route("/unread", name="unread")
17 * @return \Symfony\Component\HttpFoundation\Response
13 */ 18 */
14 public function showUnreadAction() 19 public function showUnreadAction()
15 { 20 {
16 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); 21 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
17 $entries = $repository->findUnreadByUser(1); 22 $entries = $repository->findUnreadByUser(1, 0);
18 23
19 return $this->render( 24 return $this->render(
20 'WallabagBundle:Entry:entries.html.twig', 25 'WallabagBundle:Entry:entries.html.twig',
21 array('entries' => $entries) 26 array('entries' => $entries)
22 ); 27 );
23
24 } 28 }
25 29
26 /** 30 /**
31 * Shows read entries for current user
32 *
27 * @Route("/archive", name="archive") 33 * @Route("/archive", name="archive")
34 * @return \Symfony\Component\HttpFoundation\Response
28 */ 35 */
29 public function showArchiveAction() 36 public function showArchiveAction()
30 { 37 {
31 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); 38 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
32 $entries = $repository->findArchiveByUser(1); 39 $entries = $repository->findArchiveByUser(1, 0);
33 40
34 return $this->render( 41 return $this->render(
35 'WallabagBundle:Entry:entries.html.twig', 42 'WallabagBundle:Entry:entries.html.twig',
36 array('entries' => $entries) 43 array('entries' => $entries)
37 ); 44 );
38
39 } 45 }
40 46
41 /** 47 /**
48 * Shows starred entries for current user
49 *
42 * @Route("/starred", name="starred") 50 * @Route("/starred", name="starred")
51 * @return \Symfony\Component\HttpFoundation\Response
43 */ 52 */
44 public function showStarredAction() 53 public function showStarredAction()
45 { 54 {
46 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); 55 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
47 $entries = $repository->findStarredByUser(1); 56 $entries = $repository->findStarredByUser(1, 0);
48 57
49 return $this->render( 58 return $this->render(
50 'WallabagBundle:Entry:entries.html.twig', 59 'WallabagBundle:Entry:entries.html.twig',
51 array('entries' => $entries) 60 array('entries' => $entries)
52 ); 61 );
53
54 } 62 }
55 63
56 /** 64 /**
65 * Shows entry content
66 *
67 * @param Entries $entry
57 * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view") 68 * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
69 * @return \Symfony\Component\HttpFoundation\Response
58 */ 70 */
59 public function viewAction($id) 71 public function viewAction(Entries $entry)
60 { 72 {
61 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
62 $entry = $repository->find($id);
63
64 return $this->render( 73 return $this->render(
65 'WallabagBundle:Entry:entry.html.twig', 74 'WallabagBundle:Entry:entry.html.twig',
66 array('entry' => $entry) 75 array('entry' => $entry)
67 ); 76 );
77 }
78
79 /**
80 * Changes read status for an entry
81 *
82 * @param Request $request
83 * @param Entries $entry
84 * @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry")
85 * @return \Symfony\Component\HttpFoundation\RedirectResponse
86 */
87 public function toggleArchiveAction(Request $request, Entries $entry)
88 {
89 $entry->toggleArchive();
90 $this->getDoctrine()->getManager()->flush();
91
92 $this->get('session')->getFlashBag()->add(
93 'notice',
94 'Entry archived'
95 );
96
97 return $this->redirect($request->headers->get('referer'));
98 }
99
100 /**
101 * Changes favorite status for an entry
102 *
103 * @param Request $request
104 * @param Entries $entry
105 * @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry")
106 * @return \Symfony\Component\HttpFoundation\RedirectResponse
107 */
108 public function toggleStarAction(Request $request, Entries $entry)
109 {
110 $entry->toggleStar();
111 $this->getDoctrine()->getManager()->flush();
112
113 $this->get('session')->getFlashBag()->add(
114 'notice',
115 'Entry starred'
116 );
117
118 return $this->redirect($request->headers->get('referer'));
119 }
120
121 /**
122 * Deletes entry
123 *
124 * @param Request $request
125 * @param Entries $entry
126 * @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry")
127 * @return \Symfony\Component\HttpFoundation\RedirectResponse
128 */
129 public function deleteEntryAction(Request $request, Entries $entry)
130 {
131 $em = $this->getDoctrine()->getEntityManager();
132 $em->remove($entry);
133 $em->flush();
134
135 $this->get('session')->getFlashBag()->add(
136 'notice',
137 'Entry deleted'
138 );
68 139
140 return $this->redirect($request->headers->get('referer'));
69 } 141 }
70} 142}