mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Entry: add archived_at property and updateArchived method
This commit is contained in:
parent
2f3af70e1a
commit
7975395d10
13 changed files with 132 additions and 15 deletions
|
@ -86,6 +86,15 @@ class Entry
|
|||
*/
|
||||
private $isArchived = false;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="archived_at", type="datetime", nullable=true)
|
||||
*
|
||||
* @Groups({"entries_for_user", "export_all"})
|
||||
*/
|
||||
private $archivedAt = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
|
@ -335,6 +344,44 @@ class Entry
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* update isArchived and archive_at fields.
|
||||
*
|
||||
* @param bool $isArchived
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function updateArchived($isArchived = false)
|
||||
{
|
||||
$this->setArchived($isArchived);
|
||||
$this->setArchivedAt(null);
|
||||
if ($this->isArchived()) {
|
||||
$this->setArchivedAt(new \DateTime());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getArchivedAt()
|
||||
{
|
||||
return $this->archivedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $archivedAt
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function setArchivedAt($archivedAt = null)
|
||||
{
|
||||
$this->archivedAt = $archivedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get isArchived.
|
||||
*
|
||||
|
@ -357,7 +404,7 @@ class Entry
|
|||
|
||||
public function toggleArchive()
|
||||
{
|
||||
$this->isArchived = $this->isArchived() ^ 1;
|
||||
$this->updateArchived($this->isArchived() ^ 1);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue