]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Share entry with a public URL
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index ceae78b05556e4005f0c51e35e1eb93a5bf6c57a..3c742828522935830b11bc90c426946ef63acbdb 100644 (file)
@@ -37,6 +37,15 @@ class Entry
      */
     private $id;
 
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="uuid", type="text", nullable=true)
+     *
+     * @Groups({"entries_for_user", "export_all"})
+     */
+    private $uuid;
+
     /**
      * @var string
      *
@@ -427,6 +436,8 @@ class Entry
         }
 
         $this->updatedAt = new \DateTime();
+
+        $this->generateUuid();
     }
 
     /**
@@ -595,4 +606,31 @@ class Entry
     {
         return $this->language;
     }
+
+    /**
+     * @return int
+     */
+    public function getUuid()
+    {
+        return $this->uuid;
+    }
+
+    /**
+     * @param int $uuid
+     *
+     * @return Entry
+     */
+    public function setUuid($uuid)
+    {
+        $this->uuid = $uuid;
+
+        return $this;
+    }
+
+    public function generateUuid()
+    {
+        if (empty($this->uuid) || is_null($this->uuid)) {
+            $this->uuid = uniqid();
+        }
+    }
 }