mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-31 18:31:02 +00:00
Set a starred_at field when an entry is starred.
This date is used to sort starred entries. Can not use Entry::timestamps method otherwise starred_at will be updated each time entry is updated. Add an updateStar method into Entry class A migration script has been added in order to set starred_at field.
This commit is contained in:
parent
2490f61dca
commit
a991c46eed
6 changed files with 124 additions and 7 deletions
|
@ -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
|
||||
|
@ -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>
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue