aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@smile.fr>2015-10-26 14:38:24 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-01-02 23:24:17 +0100
commitdda57bb9443817e3a080d5d25343f5a7e15dd14f (patch)
tree75a2447f84aad68ff6a1efe01019b77a2148d339 /src/Wallabag/CoreBundle
parent87f23b005c5f68f7463333a74317efa4eb9a9565 (diff)
downloadwallabag-dda57bb9443817e3a080d5d25343f5a7e15dd14f.tar.gz
wallabag-dda57bb9443817e3a080d5d25343f5a7e15dd14f.tar.zst
wallabag-dda57bb9443817e3a080d5d25343f5a7e15dd14f.zip
fix #1502 avoid duplicate entry and store pocket url in config
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index fa580133..de2eedcb 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -41,6 +41,7 @@ class EntryController extends Controller
41 */ 41 */
42 public function addEntryFormAction(Request $request) 42 public function addEntryFormAction(Request $request)
43 { 43 {
44 $em = $this->getDoctrine()->getManager();
44 $entry = new Entry($this->getUser()); 45 $entry = new Entry($this->getUser());
45 46
46 $form = $this->createForm(new NewEntryType(), $entry); 47 $form = $this->createForm(new NewEntryType(), $entry);
@@ -48,6 +49,19 @@ class EntryController extends Controller
48 $form->handleRequest($request); 49 $form->handleRequest($request);
49 50
50 if ($form->isValid()) { 51 if ($form->isValid()) {
52 $existingEntry = $em
53 ->getRepository('WallabagCoreBundle:Entry')
54 ->findOneByUrl($entry->getUrl());
55
56 if (!is_null($existingEntry)) {
57 $this->get('session')->getFlashBag()->add(
58 'notice',
59 'Entry already saved on '.$existingEntry->getCreatedAt()->format('d-m-Y')
60 );
61
62 return $this->redirect($this->generateUrl('view', array('id' => $existingEntry->getId())));
63 }
64
51 $this->updateEntry($entry); 65 $this->updateEntry($entry);
52 $this->get('session')->getFlashBag()->add( 66 $this->get('session')->getFlashBag()->add(
53 'notice', 67 'notice',