aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php24
-rw-r--r--src/Wallabag/CoreBundle/Controller/FooterController.php27
-rw-r--r--src/Wallabag/CoreBundle/Controller/StaticController.php4
3 files changed, 46 insertions, 9 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 69dfd4b1..4eb314f7 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -23,10 +23,16 @@ class EntryController extends Controller
23 { 23 {
24 try { 24 try {
25 $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); 25 $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
26
26 $em = $this->getDoctrine()->getManager(); 27 $em = $this->getDoctrine()->getManager();
27 $em->persist($entry); 28 $em->persist($entry);
28 $em->flush(); 29 $em->flush();
29 } catch (\Exception $e) { 30 } catch (\Exception $e) {
31 $this->get('logger')->error('Error while saving an entry', [
32 'exception' => $e,
33 'entry' => $entry,
34 ]);
35
30 return false; 36 return false;
31 } 37 }
32 38
@@ -60,11 +66,12 @@ class EntryController extends Controller
60 return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()])); 66 return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()]));
61 } 67 }
62 68
63 $this->updateEntry($entry); 69 $message = 'flashes.entry.notice.entry_saved';
64 $this->get('session')->getFlashBag()->add( 70 if (false === $this->updateEntry($entry)) {
65 'notice', 71 $message = 'flashes.entry.notice.entry_saved_failed';
66 'flashes.entry.notice.entry_saved' 72 }
67 ); 73
74 $this->get('session')->getFlashBag()->add('notice', $message);
68 75
69 return $this->redirect($this->generateUrl('homepage')); 76 return $this->redirect($this->generateUrl('homepage'));
70 } 77 }
@@ -399,7 +406,7 @@ class EntryController extends Controller
399 $url = $this->generateUrl( 406 $url = $this->generateUrl(
400 'view', 407 'view',
401 ['id' => $entry->getId()], 408 ['id' => $entry->getId()],
402 UrlGeneratorInterface::ABSOLUTE_URL 409 UrlGeneratorInterface::ABSOLUTE_PATH
403 ); 410 );
404 411
405 $em = $this->getDoctrine()->getManager(); 412 $em = $this->getDoctrine()->getManager();
@@ -411,8 +418,9 @@ class EntryController extends Controller
411 'flashes.entry.notice.entry_deleted' 418 'flashes.entry.notice.entry_deleted'
412 ); 419 );
413 420
414 // don't redirect user to the deleted entry 421 // don't redirect user to the deleted entry (check that the referer doesn't end with the same url)
415 $to = ($url !== $request->headers->get('referer') ? $request->headers->get('referer') : null); 422 $referer = $request->headers->get('referer');
423 $to = (1 !== preg_match('#'.$url.'$#i', $referer) ? $referer : null);
416 424
417 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to); 425 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to);
418 426
diff --git a/src/Wallabag/CoreBundle/Controller/FooterController.php b/src/Wallabag/CoreBundle/Controller/FooterController.php
new file mode 100644
index 00000000..fd93c436
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Controller/FooterController.php
@@ -0,0 +1,27 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
7class FooterController extends Controller
8{
9 /**
10 * Display the footer.
11 *
12 * @return \Symfony\Component\HttpFoundation\Response
13 */
14 public function indexAction()
15 {
16 $addonsUrl = $this->container->getParameter('addons_url');
17 $socialsUrl = $this->container->getParameter('socials_url');
18
19 return $this->render(
20 'WallabagCoreBundle::footer.html.twig',
21 [
22 'addonsUrl' => $addonsUrl,
23 'socialsUrl' => $socialsUrl,
24 ]
25 );
26 }
27}
diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php
index b41302f8..2a57f06f 100644
--- a/src/Wallabag/CoreBundle/Controller/StaticController.php
+++ b/src/Wallabag/CoreBundle/Controller/StaticController.php
@@ -12,9 +12,11 @@ class StaticController extends Controller
12 */ 12 */
13 public function howtoAction() 13 public function howtoAction()
14 { 14 {
15 $addonsUrl = $this->container->getParameter('addons_url');
16
15 return $this->render( 17 return $this->render(
16 'WallabagCoreBundle:Static:howto.html.twig', 18 'WallabagCoreBundle:Static:howto.html.twig',
17 [] 19 ['addonsUrl' => $addonsUrl]
18 ); 20 );
19 } 21 }
20 22