aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/WallabagBundle/Controller
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-01-23 16:28:37 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-01-23 16:28:37 +0100
commitad4d1caa9e744af57ca58a4e57576533eb682d00 (patch)
tree37d6c284d2afc7fc62cdf80be419b536ab4ea603 /src/WallabagBundle/Controller
parentb84a80559a1167b5500fbc5eb4965d3b08b371ef (diff)
downloadwallabag-ad4d1caa9e744af57ca58a4e57576533eb682d00.tar.gz
wallabag-ad4d1caa9e744af57ca58a4e57576533eb682d00.tar.zst
wallabag-ad4d1caa9e744af57ca58a4e57576533eb682d00.zip
move WallabagBundle into Wallabag:CoreBundle
Diffstat (limited to 'src/WallabagBundle/Controller')
-rw-r--r--src/WallabagBundle/Controller/EntryController.php184
-rw-r--r--src/WallabagBundle/Controller/StaticController.php20
2 files changed, 0 insertions, 204 deletions
diff --git a/src/WallabagBundle/Controller/EntryController.php b/src/WallabagBundle/Controller/EntryController.php
deleted file mode 100644
index dc1876fa..00000000
--- a/src/WallabagBundle/Controller/EntryController.php
+++ /dev/null
@@ -1,184 +0,0 @@
1<?php
2
3namespace WallabagBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request;
8use WallabagBundle\Repository;
9use WallabagBundle\Entity\Entries;
10use Wallabag\Wallabag\Tools;
11use Wallabag\Wallabag\Url;
12
13class EntryController extends Controller
14{
15
16 /**
17 * @param Request $request
18 * @Route("/new", name="new_entry")
19 * @return \Symfony\Component\HttpFoundation\Response
20 */
21 public function addEntryAction(Request $request)
22 {
23 $entry = new Entries();
24 $entry->setUserId(1);
25
26 $form = $this->createFormBuilder($entry)
27 ->add('url', 'url')
28 ->add('save', 'submit')
29 ->getForm();
30
31 $form->handleRequest($request);
32
33 if ($form->isValid()) {
34
35 $content = Tools::getPageContent(new Url($entry->getUrl()));
36 var_dump($content);die;
37
38 $em = $this->getDoctrine()->getEntityManager();
39 $em->persist($entry);
40 $em->flush();
41
42 $this->get('session')->getFlashBag()->add(
43 'notice',
44 'Entry saved'
45 );
46
47 return $this->redirect($this->generateUrl('homepage'));
48 }
49
50 return $this->render('WallabagBundle:Entry:new.html.twig', array(
51 'form' => $form->createView(),
52 ));
53 }
54
55 /**
56 * Shows unread entries for current user
57 *
58 * @Route("/unread", name="unread")
59 * @return \Symfony\Component\HttpFoundation\Response
60 */
61 public function showUnreadAction()
62 {
63 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
64 $entries = $repository->findUnreadByUser(1, 0);
65
66 return $this->render(
67 'WallabagBundle:Entry:entries.html.twig',
68 array('entries' => $entries)
69 );
70 }
71
72 /**
73 * Shows read entries for current user
74 *
75 * @Route("/archive", name="archive")
76 * @return \Symfony\Component\HttpFoundation\Response
77 */
78 public function showArchiveAction()
79 {
80 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
81 $entries = $repository->findArchiveByUser(1, 0);
82
83 return $this->render(
84 'WallabagBundle:Entry:entries.html.twig',
85 array('entries' => $entries)
86 );
87 }
88
89 /**
90 * Shows starred entries for current user
91 *
92 * @Route("/starred", name="starred")
93 * @return \Symfony\Component\HttpFoundation\Response
94 */
95 public function showStarredAction()
96 {
97 $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
98 $entries = $repository->findStarredByUser(1, 0);
99
100 return $this->render(
101 'WallabagBundle:Entry:entries.html.twig',
102 array('entries' => $entries)
103 );
104 }
105
106 /**
107 * Shows entry content
108 *
109 * @param Entries $entry
110 * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
111 * @return \Symfony\Component\HttpFoundation\Response
112 */
113 public function viewAction(Entries $entry)
114 {
115 return $this->render(
116 'WallabagBundle:Entry:entry.html.twig',
117 array('entry' => $entry)
118 );
119 }
120
121 /**
122 * Changes read status for an entry
123 *
124 * @param Request $request
125 * @param Entries $entry
126 * @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry")
127 * @return \Symfony\Component\HttpFoundation\RedirectResponse
128 */
129 public function toggleArchiveAction(Request $request, Entries $entry)
130 {
131 $entry->toggleArchive();
132 $this->getDoctrine()->getManager()->flush();
133
134 $this->get('session')->getFlashBag()->add(
135 'notice',
136 'Entry archived'
137 );
138
139 return $this->redirect($request->headers->get('referer'));
140 }
141
142 /**
143 * Changes favorite status for an entry
144 *
145 * @param Request $request
146 * @param Entries $entry
147 * @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry")
148 * @return \Symfony\Component\HttpFoundation\RedirectResponse
149 */
150 public function toggleStarAction(Request $request, Entries $entry)
151 {
152 $entry->toggleStar();
153 $this->getDoctrine()->getManager()->flush();
154
155 $this->get('session')->getFlashBag()->add(
156 'notice',
157 'Entry starred'
158 );
159
160 return $this->redirect($request->headers->get('referer'));
161 }
162
163 /**
164 * Deletes entry
165 *
166 * @param Request $request
167 * @param Entries $entry
168 * @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry")
169 * @return \Symfony\Component\HttpFoundation\RedirectResponse
170 */
171 public function deleteEntryAction(Request $request, Entries $entry)
172 {
173 $em = $this->getDoctrine()->getEntityManager();
174 $em->remove($entry);
175 $em->flush();
176
177 $this->get('session')->getFlashBag()->add(
178 'notice',
179 'Entry deleted'
180 );
181
182 return $this->redirect($request->headers->get('referer'));
183 }
184}
diff --git a/src/WallabagBundle/Controller/StaticController.php b/src/WallabagBundle/Controller/StaticController.php
deleted file mode 100644
index aee2bb7e..00000000
--- a/src/WallabagBundle/Controller/StaticController.php
+++ /dev/null
@@ -1,20 +0,0 @@
1<?php
2
3namespace WallabagBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
8class StaticController extends Controller
9{
10 /**
11 * @Route("/about", name="about")
12 */
13 public function aboutAction()
14 {
15 return $this->render(
16 'WallabagBundle:Static:about.html.twig',
17 array()
18 );
19 }
20}