aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index fa633031..cba58858 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -49,8 +49,7 @@ class EntryController extends Controller
49 $form->handleRequest($request); 49 $form->handleRequest($request);
50 50
51 if ($form->isValid()) { 51 if ($form->isValid()) {
52 // check for existing entry, if it exists, redirect to it with a message 52 $existingEntry = $this->checkIfEntryAlreadyExists($entry);
53 $existingEntry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
54 53
55 if (false !== $existingEntry) { 54 if (false !== $existingEntry) {
56 $this->get('session')->getFlashBag()->add( 55 $this->get('session')->getFlashBag()->add(
@@ -86,7 +85,10 @@ class EntryController extends Controller
86 { 85 {
87 $entry = new Entry($this->getUser()); 86 $entry = new Entry($this->getUser());
88 $entry->setUrl($request->get('url')); 87 $entry->setUrl($request->get('url'));
89 $this->updateEntry($entry); 88
89 if (false === $this->checkIfEntryAlreadyExists($entry)) {
90 $this->updateEntry($entry);
91 }
90 92
91 return $this->redirect($this->generateUrl('homepage')); 93 return $this->redirect($this->generateUrl('homepage'));
92 } 94 }
@@ -420,4 +422,16 @@ class EntryController extends Controller
420 throw $this->createAccessDeniedException('You can not access this entry.'); 422 throw $this->createAccessDeniedException('You can not access this entry.');
421 } 423 }
422 } 424 }
425
426 /**
427 * Check for existing entry, if it exists, redirect to it with a message.
428 *
429 * @param $entry
430 *
431 * @return array|bool
432 */
433 private function checkIfEntryAlreadyExists($entry)
434 {
435 return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
436 }
423} 437}