$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(
$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);
}
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());
+ }
}