aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-08-24 22:29:36 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-08-24 22:29:36 +0200
commiteddda878a0ec375fa738e3228a72dd01b23e0fab (patch)
tree7bc8bb34a14d09f0e75ddc052e560486bb6d69b7 /src/Wallabag
parentb1afef30dc5527e5bf57c3eff60b05ee478a6014 (diff)
downloadwallabag-eddda878a0ec375fa738e3228a72dd01b23e0fab.tar.gz
wallabag-eddda878a0ec375fa738e3228a72dd01b23e0fab.tar.zst
wallabag-eddda878a0ec375fa738e3228a72dd01b23e0fab.zip
Update test
and some cleanup
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php30
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php2
2 files changed, 15 insertions, 17 deletions
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
465 { 465 {
466 $this->checkUserAction($entry); 466 $this->checkUserAction($entry);
467 467
468 if ('' === $entry->getUuid() || null === $entry->getUuid()) { 468 if (null === $entry->getUuid()) {
469 $this->generateEntryUuid($entry); 469 $entry->generateUuid();
470
471 $em = $this->getDoctrine()->getManager();
472 $em->persist($entry);
473 $em->flush();
470 } 474 }
471 475
472 return $this->redirect($this->generateUrl('share_entry', [ 476 return $this->redirect($this->generateUrl('share_entry', [
@@ -488,6 +492,7 @@ class EntryController extends Controller
488 $this->checkUserAction($entry); 492 $this->checkUserAction($entry);
489 493
490 $entry->cleanUuid(); 494 $entry->cleanUuid();
495
491 $em = $this->getDoctrine()->getManager(); 496 $em = $this->getDoctrine()->getManager();
492 $em->persist($entry); 497 $em->persist($entry);
493 $em->flush(); 498 $em->flush();
@@ -498,31 +503,24 @@ class EntryController extends Controller
498 } 503 }
499 504
500 /** 505 /**
501 * Share entry content. 506 * Ability to view a content publicly.
502 * 507 *
503 * @param Entry $entry 508 * @param Entry $entry
504 * 509 *
505 * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry") 510 * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry")
506 * @Cache(maxage="25200", public=true) 511 * @Cache(maxage="25200", smaxage="25200", public=true)
507 * 512 *
508 * @return \Symfony\Component\HttpFoundation\Response 513 * @return \Symfony\Component\HttpFoundation\Response
509 */ 514 */
510 public function shareEntryAction(Entry $entry) 515 public function shareEntryAction(Entry $entry)
511 { 516 {
517 if (!$this->get('craue_config')->get('share_public')) {
518 throw $this->createAccessDeniedException('Sharing an entry is disabled for this user.');
519 }
520
512 return $this->render( 521 return $this->render(
513 '@WallabagCore/themes/share.html.twig', 522 '@WallabagCore/themes/share.html.twig',
514 array('entry' => $entry) 523 ['entry' => $entry]
515 ); 524 );
516 } 525 }
517
518 /**
519 * @param Entry $entry
520 */
521 private function generateEntryUuid(Entry $entry)
522 {
523 $entry->generateUuid();
524 $em = $this->getDoctrine()->getManager();
525 $em->persist($entry);
526 $em->flush();
527 }
528} 526}
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 67c2bb43..4d7e001b 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -627,7 +627,7 @@ class Entry
627 627
628 public function generateUuid() 628 public function generateUuid()
629 { 629 {
630 if (empty($this->uuid) || is_null($this->uuid)) { 630 if (null === $this->uuid) {
631 // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter 631 // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter
632 $this->uuid = uniqid('', true); 632 $this->uuid = uniqid('', true);
633 } 633 }