diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 9097810c..37f7ab60 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -41,7 +41,6 @@ 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(); | ||
45 | $entry = new Entry($this->getUser()); | 44 | $entry = new Entry($this->getUser()); |
46 | 45 | ||
47 | $form = $this->createForm(new NewEntryType(), $entry); | 46 | $form = $this->createForm(new NewEntryType(), $entry); |
@@ -49,17 +48,17 @@ class EntryController extends Controller | |||
49 | $form->handleRequest($request); | 48 | $form->handleRequest($request); |
50 | 49 | ||
51 | if ($form->isValid()) { | 50 | if ($form->isValid()) { |
52 | $existingEntry = $em | 51 | // check for existing entry, if it exists, redirect to it with a message |
53 | ->getRepository('WallabagCoreBundle:Entry') | 52 | $existingEntry = $this->get('wallabag_core.entry_repository') |
54 | ->findOneByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); | 53 | ->existByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); |
55 | 54 | ||
56 | if (count($existingEntry) > 0) { | 55 | if (false !== $existingEntry) { |
57 | $this->get('session')->getFlashBag()->add( | 56 | $this->get('session')->getFlashBag()->add( |
58 | 'notice', | 57 | 'notice', |
59 | 'Entry already saved on '.$existingEntry[0]->getCreatedAt()->format('d-m-Y') | 58 | 'Entry already saved on '.$existingEntry['createdAt']->format('d-m-Y') |
60 | ); | 59 | ); |
61 | 60 | ||
62 | return $this->redirect($this->generateUrl('view', array('id' => $existingEntry[0]->getId()))); | 61 | return $this->redirect($this->generateUrl('view', array('id' => $existingEntry['id']))); |
63 | } | 62 | } |
64 | 63 | ||
65 | $this->updateEntry($entry); | 64 | $this->updateEntry($entry); |