]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Merge pull request #3011 from wallabag/2.3
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index 61d01bdcdadd5f0a52ceb3e66f08ae1eb0228cb9..cfb8db75275c2e42d1b994e5f037a58220bd31d5 100644 (file)
@@ -142,6 +142,15 @@ class Entry
      */
     private $publishedBy;
 
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="starred_at", type="datetime", nullable=true)
+     *
+     * @Groups({"entries_for_user", "export_all"})
+     */
+    private $starredAt = null;
+
     /**
      * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"})
      * @ORM\JoinTable
@@ -171,11 +180,11 @@ class Entry
     /**
      * @var int
      *
-     * @ORM\Column(name="reading_time", type="integer", nullable=true)
+     * @ORM\Column(name="reading_time", type="integer", nullable=false)
      *
      * @Groups({"entries_for_user", "export_all"})
      */
-    private $readingTime;
+    private $readingTime = 0;
 
     /**
      * @var string
@@ -475,6 +484,44 @@ class Entry
         return $this->updatedAt;
     }
 
+    /**
+     * @return \DateTime|null
+     */
+    public function getStarredAt()
+    {
+        return $this->starredAt;
+    }
+
+    /**
+     * @param \DateTime|null $starredAt
+     *
+     * @return Entry
+     */
+    public function setStarredAt($starredAt = null)
+    {
+        $this->starredAt = $starredAt;
+
+        return $this;
+    }
+
+    /**
+     * update isStarred and starred_at fields.
+     *
+     * @param bool $isStarred
+     *
+     * @return Entry
+     */
+    public function updateStar($isStarred = false)
+    {
+        $this->setStarred($isStarred);
+        $this->setStarredAt(null);
+        if ($this->isStarred()) {
+            $this->setStarredAt(new \DateTime());
+        }
+
+        return $this;
+    }
+
     /**
      * @return ArrayCollection<Annotation>
      */