X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FEntryController.php;h=177597ba8aa8bb3d0e050c807521369d8e51fe80;hb=b00a89e08f8811297cf81f71ead1433a101d5737;hp=1d0df889e00043731565d485889966c8a946ccc3;hpb=f652f41dab0b456d24295c8ff47155f28e63f1ed;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 1d0df889..177597ba 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -49,8 +49,7 @@ class EntryController extends Controller $form->handleRequest($request); if ($form->isValid()) { - // check for existing entry, if it exists, redirect to it with a message - $existingEntry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); + $existingEntry = $this->checkIfEntryAlreadyExists($entry); if (false !== $existingEntry) { $this->get('session')->getFlashBag()->add( @@ -87,10 +86,7 @@ class EntryController extends Controller $entry = new Entry($this->getUser()); $entry->setUrl($request->get('url')); - // check for existing entry, if it exists, redirect to it with a message - $existingEntry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); - - if (false === $existingEntry) { + if (false === $this->checkIfEntryAlreadyExists($entry)) { $this->updateEntry($entry); } @@ -426,4 +422,16 @@ class EntryController extends Controller throw $this->createAccessDeniedException('You can not access this entry.'); } } + + /** + * Check for existing entry, if it exists, redirect to it with a message. + * + * @param $entry + * + * @return array|bool + */ + public function checkIfEntryAlreadyExists($entry) + { + return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); + } }