1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-12 16:58:37 +00:00

fix #1502 avoid duplicate entry and store pocket url in config

This commit is contained in:
Nicolas Lœuillet 2015-10-26 14:38:24 +01:00 committed by Jeremy Benoist
parent 87f23b005c
commit dda57bb944
7 changed files with 87 additions and 36 deletions

View file

@ -41,6 +41,7 @@ class EntryController extends Controller
*/
public function addEntryFormAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$entry = new Entry($this->getUser());
$form = $this->createForm(new NewEntryType(), $entry);
@ -48,6 +49,19 @@ class EntryController extends Controller
$form->handleRequest($request);
if ($form->isValid()) {
$existingEntry = $em
->getRepository('WallabagCoreBundle:Entry')
->findOneByUrl($entry->getUrl());
if (!is_null($existingEntry)) {
$this->get('session')->getFlashBag()->add(
'notice',
'Entry already saved on '.$existingEntry->getCreatedAt()->format('d-m-Y')
);
return $this->redirect($this->generateUrl('view', array('id' => $existingEntry->getId())));
}
$this->updateEntry($entry);
$this->get('session')->getFlashBag()->add(
'notice',