diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 40 |
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; | |||
15 | class EntryController extends Controller | 15 | class 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 |