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
|
@ -358,7 +358,7 @@ class EntryRestController extends WallabagRestController
|
|||
}
|
||||
|
||||
if (null !== $data['isArchived']) {
|
||||
$entry->setArchived((bool) $data['isArchived']);
|
||||
$entry->updateArchived((bool) $data['isArchived']);
|
||||
}
|
||||
|
||||
if (null !== $data['isStarred']) {
|
||||
|
@ -474,7 +474,7 @@ class EntryRestController extends WallabagRestController
|
|||
}
|
||||
|
||||
if (null !== $data['isArchived']) {
|
||||
$entry->setArchived((bool) $data['isArchived']);
|
||||
$entry->updateArchived((bool) $data['isArchived']);
|
||||
}
|
||||
|
||||
if (null !== $data['isStarred']) {
|
||||
|
|
|
@ -98,7 +98,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
|
|||
$entry6->setMimetype('text/html');
|
||||
$entry6->setTitle('test title entry6');
|
||||
$entry6->setContent('This is my content /o/');
|
||||
$entry6->setArchived(true);
|
||||
$entry6->updateArchived(true);
|
||||
$entry6->setLanguage('de');
|
||||
$entry6->addTag($this->getReference('bar-tag'));
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ abstract class BrowserImport extends AbstractImport
|
|||
);
|
||||
}
|
||||
|
||||
$entry->setArchived($data['is_archived']);
|
||||
$entry->updateArchived($data['is_archived']);
|
||||
|
||||
if (!empty($data['created_at'])) {
|
||||
$dt = new \DateTime();
|
||||
|
|
|
@ -135,7 +135,7 @@ class InstapaperImport extends AbstractImport
|
|||
);
|
||||
}
|
||||
|
||||
$entry->setArchived($importedEntry['is_archived']);
|
||||
$entry->updateArchived($importedEntry['is_archived']);
|
||||
$entry->setStarred($importedEntry['is_starred']);
|
||||
|
||||
$this->em->persist($entry);
|
||||
|
|
|
@ -119,7 +119,7 @@ class PinboardImport extends AbstractImport
|
|||
);
|
||||
}
|
||||
|
||||
$entry->setArchived($data['is_archived']);
|
||||
$entry->updateArchived($data['is_archived']);
|
||||
$entry->setStarred($data['is_starred']);
|
||||
$entry->setCreatedAt(new \DateTime($data['created_at']));
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ class PocketImport extends AbstractImport
|
|||
$this->fetchContent($entry, $url);
|
||||
|
||||
// 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
|
||||
$entry->setArchived(1 === $importedEntry['status'] || $this->markAsRead);
|
||||
$entry->updateArchived(1 === $importedEntry['status'] || $this->markAsRead);
|
||||
|
||||
// 0 or 1 - 1 If the item is starred
|
||||
$entry->setStarred(1 === $importedEntry['favorite']);
|
||||
|
|
|
@ -111,7 +111,7 @@ class ReadabilityImport extends AbstractImport
|
|||
// update entry with content (in case fetching failed, the given entry will be return)
|
||||
$this->fetchContent($entry, $data['url'], $data);
|
||||
|
||||
$entry->setArchived($data['is_archived']);
|
||||
$entry->updateArchived($data['is_archived']);
|
||||
$entry->setStarred($data['is_starred']);
|
||||
$entry->setCreatedAt(new \DateTime($data['created_at']));
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ abstract class WallabagImport extends AbstractImport
|
|||
$entry->setPreviewPicture($importedEntry['preview_picture']);
|
||||
}
|
||||
|
||||
$entry->setArchived($data['is_archived']);
|
||||
$entry->updateArchived($data['is_archived']);
|
||||
$entry->setStarred($data['is_starred']);
|
||||
|
||||
if (!empty($data['created_at'])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue