diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
3 files changed, 47 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 69dfd4b1..ccdf9406 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 | } |
@@ -350,7 +357,7 @@ class EntryController extends Controller | |||
350 | } | 357 | } |
351 | 358 | ||
352 | /** | 359 | /** |
353 | * Changes favorite status for an entry. | 360 | * Changes starred status for an entry. |
354 | * | 361 | * |
355 | * @param Request $request | 362 | * @param Request $request |
356 | * @param Entry $entry | 363 | * @param Entry $entry |
@@ -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 | |||
3 | namespace Wallabag\CoreBundle\Controller; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | |||
7 | class 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 | ||