From eddda878a0ec375fa738e3228a72dd01b23e0fab Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 24 Aug 2016 22:29:36 +0200 Subject: Update test and some cleanup --- .../CoreBundle/Controller/EntryController.php | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/Wallabag/CoreBundle/Controller') diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index e500ad75..d71ba6cd 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -465,8 +465,12 @@ class EntryController extends Controller { $this->checkUserAction($entry); - if ('' === $entry->getUuid() || null === $entry->getUuid()) { - $this->generateEntryUuid($entry); + if (null === $entry->getUuid()) { + $entry->generateUuid(); + + $em = $this->getDoctrine()->getManager(); + $em->persist($entry); + $em->flush(); } return $this->redirect($this->generateUrl('share_entry', [ @@ -488,6 +492,7 @@ class EntryController extends Controller $this->checkUserAction($entry); $entry->cleanUuid(); + $em = $this->getDoctrine()->getManager(); $em->persist($entry); $em->flush(); @@ -498,31 +503,24 @@ class EntryController extends Controller } /** - * Share entry content. + * Ability to view a content publicly. * * @param Entry $entry * * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry") - * @Cache(maxage="25200", public=true) + * @Cache(maxage="25200", smaxage="25200", public=true) * * @return \Symfony\Component\HttpFoundation\Response */ public function shareEntryAction(Entry $entry) { + if (!$this->get('craue_config')->get('share_public')) { + throw $this->createAccessDeniedException('Sharing an entry is disabled for this user.'); + } + return $this->render( '@WallabagCore/themes/share.html.twig', - array('entry' => $entry) + ['entry' => $entry] ); } - - /** - * @param Entry $entry - */ - private function generateEntryUuid(Entry $entry) - { - $entry->generateUuid(); - $em = $this->getDoctrine()->getManager(); - $em->persist($entry); - $em->flush(); - } } -- cgit v1.2.3