aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/EntryController.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@smile.fr>2015-10-07 18:08:51 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@smile.fr>2015-10-08 13:29:41 +0200
commit880a0e1c0ba7d0ab3320678b076402379a08c8a2 (patch)
tree2d3d53811a7988974543fc61c70e55ac70e9be5b /src/Wallabag/CoreBundle/Controller/EntryController.php
parent3bfbd22f13e778c6b9713cde0cdf5b7b824f1ff2 (diff)
downloadwallabag-880a0e1c0ba7d0ab3320678b076402379a08c8a2.tar.gz
wallabag-880a0e1c0ba7d0ab3320678b076402379a08c8a2.tar.zst
wallabag-880a0e1c0ba7d0ab3320678b076402379a08c8a2.zip
implement bookmarklet
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index a9f35c36..f7b52eaf 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -15,6 +15,23 @@ use Pagerfanta\Pagerfanta;
15class EntryController extends Controller 15class EntryController extends Controller
16{ 16{
17 /** 17 /**
18 * @param Entry $entry
19 */
20 private function updateEntry(Entry $entry)
21 {
22 try {
23 $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
24 $em = $this->getDoctrine()->getManager();
25 $em->persist($entry);
26 $em->flush();
27 } catch (\Exception $e) {
28 return false;
29 }
30
31 return true;
32 }
33
34 /**
18 * @param Request $request 35 * @param Request $request
19 * 36 *
20 * @Route("/new-entry", name="new_entry") 37 * @Route("/new-entry", name="new_entry")
@@ -30,12 +47,7 @@ class EntryController extends Controller
30 $form->handleRequest($request); 47 $form->handleRequest($request);
31 48
32 if ($form->isValid()) { 49 if ($form->isValid()) {
33 $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); 50 $this->updateEntry($entry);
34
35 $em = $this->getDoctrine()->getManager();
36 $em->persist($entry);
37 $em->flush();
38
39 $this->get('session')->getFlashBag()->add( 51 $this->get('session')->getFlashBag()->add(
40 'notice', 52 'notice',
41 'Entry saved' 53 'Entry saved'
@@ -52,6 +64,22 @@ class EntryController extends Controller
52 /** 64 /**
53 * @param Request $request 65 * @param Request $request
54 * 66 *
67 * @Route("/bookmarklet", name="bookmarklet")
68 *
69 * @return \Symfony\Component\HttpFoundation\Response
70 */
71 public function addEntryViaBookmarklet(Request $request)
72 {
73 $entry = new Entry($this->getUser());
74 $entry->setUrl($request->get('url'));
75 $this->updateEntry($entry);
76
77 return $this->redirect($this->generateUrl('homepage'));
78 }
79
80 /**
81 * @param Request $request
82 *
55 * @Route("/new", name="new") 83 * @Route("/new", name="new")
56 * 84 *
57 * @return \Symfony\Component\HttpFoundation\Response 85 * @return \Symfony\Component\HttpFoundation\Response