aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/EntryController.php
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2015-12-28 13:51:48 +0100
committerNicolas Lœuillet <nicolas@loeuillet.org>2015-12-28 13:51:48 +0100
commitc997cfcc9c161241a6398b0942a1a869688d807a (patch)
tree42c40d24baab371f5dd41eda12d3cbdbe6445a51 /src/Wallabag/CoreBundle/Controller/EntryController.php
parentd25b8288216a09fa5cf7f40e614c133a6edd8a67 (diff)
parent2863bf2ab58a4903128f60751aa416130db93e52 (diff)
downloadwallabag-c997cfcc9c161241a6398b0942a1a869688d807a.tar.gz
wallabag-c997cfcc9c161241a6398b0942a1a869688d807a.tar.zst
wallabag-c997cfcc9c161241a6398b0942a1a869688d807a.zip
Merge pull request #1540 from wallabag/v2-fix-delete
v2 – Don't redirect to the content page after deletion
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 6769799b..2f3fd6a9 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Controller;
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
8use Wallabag\CoreBundle\Entity\Entry; 9use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Form\Type\NewEntryType; 10use Wallabag\CoreBundle\Form\Type\NewEntryType;
10use Wallabag\CoreBundle\Form\Type\EditEntryType; 11use Wallabag\CoreBundle\Form\Type\EditEntryType;
@@ -316,7 +317,7 @@ class EntryController extends Controller
316 } 317 }
317 318
318 /** 319 /**
319 * Deletes entry and redirect to the homepage. 320 * Deletes entry and redirect to the homepage or the last viewed page.
320 * 321 *
321 * @param Entry $entry 322 * @param Entry $entry
322 * 323 *
@@ -328,6 +329,14 @@ class EntryController extends Controller
328 { 329 {
329 $this->checkUserAction($entry); 330 $this->checkUserAction($entry);
330 331
332 // generates the view url for this entry to check for redirection later
333 // to avoid redirecting to the deleted entry. Ugh.
334 $url = $this->generateUrl(
335 'view',
336 array('id' => $entry->getId()),
337 UrlGeneratorInterface::ABSOLUTE_URL
338 );
339
331 $em = $this->getDoctrine()->getManager(); 340 $em = $this->getDoctrine()->getManager();
332 $em->remove($entry); 341 $em->remove($entry);
333 $em->flush(); 342 $em->flush();
@@ -337,7 +346,8 @@ class EntryController extends Controller
337 'Entry deleted' 346 'Entry deleted'
338 ); 347 );
339 348
340 return $this->redirect($request->headers->get('referer')); 349 // don't redirect user to the deleted entry
350 return $this->redirect($url !== $request->headers->get('referer') ?: $this->generateUrl('homepage'));
341 } 351 }
342 352
343 /** 353 /**