diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 14 |
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', |