]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Merge pull request #2301 from wallabag/fix-rss-feeds
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index 3c742828522935830b11bc90c426946ef63acbdb..a4b0d7a82b4c436ed4bc79b6154e88590da36847 100644 (file)
@@ -38,7 +38,7 @@ class Entry
     private $id;
 
     /**
-     * @var int
+     * @var string
      *
      * @ORM\Column(name="uuid", type="text", nullable=true)
      *
@@ -97,20 +97,20 @@ class Entry
     private $content;
 
     /**
-     * @var date
+     * @var \DateTime
      *
      * @ORM\Column(name="created_at", type="datetime")
      *
-     * @Groups({"export_all"})
+     * @Groups({"entries_for_user", "export_all"})
      */
     private $createdAt;
 
     /**
-     * @var date
+     * @var \DateTime
      *
      * @ORM\Column(name="updated_at", type="datetime")
      *
-     * @Groups({"export_all"})
+     * @Groups({"entries_for_user", "export_all"})
      */
     private $updatedAt;
 
@@ -410,7 +410,22 @@ class Entry
     }
 
     /**
-     * @return string
+     * Set created_at.
+     * Only used when importing data from an other service.
+     *
+     * @param \DateTime $createdAt
+     *
+     * @return Entry
+     */
+    public function setCreatedAt(\DateTime $createdAt)
+    {
+        $this->createdAt = $createdAt;
+
+        return $this;
+    }
+
+    /**
+     * @return \DateTime
      */
     public function getCreatedAt()
     {
@@ -418,7 +433,7 @@ class Entry
     }
 
     /**
-     * @return string
+     * @return \DateTime
      */
     public function getUpdatedAt()
     {
@@ -436,8 +451,6 @@ class Entry
         }
 
         $this->updatedAt = new \DateTime();
-
-        $this->generateUuid();
     }
 
     /**
@@ -608,7 +621,7 @@ class Entry
     }
 
     /**
-     * @return int
+     * @return string
      */
     public function getUuid()
     {
@@ -616,7 +629,7 @@ class Entry
     }
 
     /**
-     * @param int $uuid
+     * @param string $uuid
      *
      * @return Entry
      */
@@ -629,8 +642,14 @@ class Entry
 
     public function generateUuid()
     {
-        if (empty($this->uuid) || is_null($this->uuid)) {
-            $this->uuid = uniqid();
+        if (null === $this->uuid) {
+            // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter
+            $this->uuid = uniqid('', true);
         }
     }
+
+    public function cleanUuid()
+    {
+        $this->uuid = null;
+    }
 }