3 namespace Wallabag\CoreBundle\Controller
;
5 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
6 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
7 use Symfony\Component\HttpFoundation\Request
;
8 use Wallabag\CoreBundle\Repository
;
9 use Wallabag\CoreBundle\Entity\Entries
;
10 use Wallabag\Wallabag\Tools
;
11 use Wallabag\Wallabag\Url
;
13 class EntryController
extends Controller
17 * @param Request $request
18 * @Route("/new", name="new_entry")
19 * @return \Symfony\Component\HttpFoundation\Response
21 public function addEntryAction(Request
$request)
23 $entry = new Entries();
26 $form = $this->createFormBuilder($entry)
28 ->add('save', 'submit')
31 $form->handleRequest($request);
33 if ($form->isValid()) {
35 $content = Tools
::getPageContent(new Url($entry->getUrl()));
36 var_dump($content);die;
38 $em = $this->getDoctrine()->getEntityManager();
42 $this->get('session')->getFlashBag()->add(
47 return $this->redirect($this->generateUrl('homepage'));
50 return $this->render('WallabagCoreBundle:Entry:new.html.twig', array(
51 'form' => $form->createView(),
56 * Shows unread entries for current user
58 * @Route("/unread", name="unread")
59 * @return \Symfony\Component\HttpFoundation\Response
61 public function showUnreadAction()
63 $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
64 $entries = $repository->findUnreadByUser(1, 0);
67 'WallabagCoreBundle:Entry:entries.html.twig',
68 array('entries' => $entries)
73 * Shows read entries for current user
75 * @Route("/archive", name="archive")
76 * @return \Symfony\Component\HttpFoundation\Response
78 public function showArchiveAction()
80 $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
81 $entries = $repository->findArchiveByUser(1, 0);
84 'WallabagCoreBundle:Entry:entries.html.twig',
85 array('entries' => $entries)
90 * Shows starred entries for current user
92 * @Route("/starred", name="starred")
93 * @return \Symfony\Component\HttpFoundation\Response
95 public function showStarredAction()
97 $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
98 $entries = $repository->findStarredByUser(1, 0);
100 return $this->render(
101 'WallabagCoreBundle:Entry:entries.html.twig',
102 array('entries' => $entries)
107 * Shows entry content
109 * @param Entries $entry
110 * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
111 * @return \Symfony\Component\HttpFoundation\Response
113 public function viewAction(Entries
$entry)
115 return $this->render(
116 'WallabagCoreBundle:Entry:entry.html.twig',
117 array('entry' => $entry)
122 * Changes read status for an entry
124 * @param Request $request
125 * @param Entries $entry
126 * @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry")
127 * @return \Symfony\Component\HttpFoundation\RedirectResponse
129 public function toggleArchiveAction(Request
$request, Entries
$entry)
131 $entry->toggleArchive();
132 $this->getDoctrine()->getManager()->flush();
134 $this->get('session')->getFlashBag()->add(
139 return $this->redirect($request->headers
->get('referer'));
143 * Changes favorite status for an entry
145 * @param Request $request
146 * @param Entries $entry
147 * @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry")
148 * @return \Symfony\Component\HttpFoundation\RedirectResponse
150 public function toggleStarAction(Request
$request, Entries
$entry)
152 $entry->toggleStar();
153 $this->getDoctrine()->getManager()->flush();
155 $this->get('session')->getFlashBag()->add(
160 return $this->redirect($request->headers
->get('referer'));
166 * @param Request $request
167 * @param Entries $entry
168 * @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry")
169 * @return \Symfony\Component\HttpFoundation\RedirectResponse
171 public function deleteEntryAction(Request
$request, Entries
$entry)
173 $em = $this->getDoctrine()->getEntityManager();
177 $this->get('session')->getFlashBag()->add(
182 return $this->redirect($request->headers
->get('referer'));