]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/EntryController.php
Add translations
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / EntryController.php
index 93db0d6caa117d1d0ba9442c8b4a3ea66ace11c8..c94b47f0db5e6f05d9926aa8cf09cbf1d4f559ea 100644 (file)
@@ -12,6 +12,7 @@ use Wallabag\CoreBundle\Entity\Entry;
 use Wallabag\CoreBundle\Form\Type\EntryFilterType;
 use Wallabag\CoreBundle\Form\Type\EditEntryType;
 use Wallabag\CoreBundle\Form\Type\NewEntryType;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
 
 class EntryController extends Controller
 {
@@ -291,6 +292,8 @@ class EntryController extends Controller
     {
         $this->checkUserAction($entry);
 
+        $this->generateEntryUuid($entry);
+
         return $this->render(
             'WallabagCoreBundle:Entry:entry.html.twig',
             ['entry' => $entry]
@@ -450,4 +453,33 @@ class EntryController extends Controller
     {
         return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
     }
+
+    /**
+     * Share entry content.
+     *
+     * @param Entry $entry
+     *
+     * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share")
+     * @Cache(maxage="25200", public=true)
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function shareEntryAction(Entry $entry)
+    {
+        return $this->render(
+            '@WallabagCore/themes/share.html.twig',
+            array('entry' => $entry)
+        );
+    }
+
+    /**
+     * @param Entry $entry
+     */
+    private function generateEntryUuid(Entry $entry)
+    {
+        $entry->generateUuid();
+        $em = $this->getDoctrine()->getManager();
+        $em->persist($entry);
+        $em->flush();
+    }
 }