diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-03-04 16:12:45 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-03-04 16:12:45 +0100 |
commit | d89908aed331779fc79b8e50ddaa51212b6269f5 (patch) | |
tree | 8087d461437d315440c825ab28433e62ce799ecc /src/Wallabag/ImportBundle/Import | |
parent | e18138dbca536ebd49c938144f9d051e5276d4ea (diff) | |
parent | 79d0e38e7ff975b2e0306d3dd96f57509fd84aef (diff) | |
download | wallabag-d89908aed331779fc79b8e50ddaa51212b6269f5.tar.gz wallabag-d89908aed331779fc79b8e50ddaa51212b6269f5.tar.zst wallabag-d89908aed331779fc79b8e50ddaa51212b6269f5.zip |
Merge pull request #1670 from wallabag/v2-mark-imported-articles-as-read
Mark all imported articles as read
Diffstat (limited to 'src/Wallabag/ImportBundle/Import')
-rw-r--r-- | src/Wallabag/ImportBundle/Import/PocketImport.php | 23 | ||||
-rw-r--r-- | src/Wallabag/ImportBundle/Import/WallabagV1Import.php | 15 | ||||
-rw-r--r-- | src/Wallabag/ImportBundle/Import/WallabagV2Import.php | 2 |
3 files changed, 37 insertions, 3 deletions
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 5dfd098c..238ddbd1 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php | |||
@@ -22,6 +22,7 @@ class PocketImport implements ImportInterface | |||
22 | private $consumerKey; | 22 | private $consumerKey; |
23 | private $skippedEntries = 0; | 23 | private $skippedEntries = 0; |
24 | private $importedEntries = 0; | 24 | private $importedEntries = 0; |
25 | private $markAsRead; | ||
25 | protected $accessToken; | 26 | protected $accessToken; |
26 | 27 | ||
27 | public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, Config $craueConfig) | 28 | public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, Config $craueConfig) |
@@ -124,6 +125,26 @@ class PocketImport implements ImportInterface | |||
124 | } | 125 | } |
125 | 126 | ||
126 | /** | 127 | /** |
128 | * Set whether articles must be all marked as read. | ||
129 | * | ||
130 | * @param bool $markAsRead | ||
131 | */ | ||
132 | public function setMarkAsRead($markAsRead) | ||
133 | { | ||
134 | $this->markAsRead = $markAsRead; | ||
135 | |||
136 | return $this; | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * Get whether articles must be all marked as read. | ||
141 | */ | ||
142 | public function getRead() | ||
143 | { | ||
144 | return $this->markAsRead; | ||
145 | } | ||
146 | |||
147 | /** | ||
127 | * {@inheritdoc} | 148 | * {@inheritdoc} |
128 | */ | 149 | */ |
129 | public function import() | 150 | public function import() |
@@ -201,7 +222,7 @@ class PocketImport implements ImportInterface | |||
201 | $entry = $this->contentProxy->updateEntry($entry, $url); | 222 | $entry = $this->contentProxy->updateEntry($entry, $url); |
202 | 223 | ||
203 | // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted | 224 | // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted |
204 | if ($pocketEntry['status'] == 1) { | 225 | if ($pocketEntry['status'] == 1 || $this->markAsRead) { |
205 | $entry->setArchived(true); | 226 | $entry->setArchived(true); |
206 | } | 227 | } |
207 | 228 | ||
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php index 05bdb401..1d773d3b 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php | |||
@@ -19,6 +19,7 @@ class WallabagV1Import implements ImportInterface | |||
19 | protected $skippedEntries = 0; | 19 | protected $skippedEntries = 0; |
20 | protected $importedEntries = 0; | 20 | protected $importedEntries = 0; |
21 | protected $filepath; | 21 | protected $filepath; |
22 | protected $markAsRead; | ||
22 | 23 | ||
23 | public function __construct(EntityManager $em, ContentProxy $contentProxy) | 24 | public function __construct(EntityManager $em, ContentProxy $contentProxy) |
24 | { | 25 | { |
@@ -121,6 +122,18 @@ class WallabagV1Import implements ImportInterface | |||
121 | } | 122 | } |
122 | 123 | ||
123 | /** | 124 | /** |
125 | * Set whether articles must be all marked as read. | ||
126 | * | ||
127 | * @param bool $markAsRead | ||
128 | */ | ||
129 | public function setMarkAsRead($markAsRead) | ||
130 | { | ||
131 | $this->markAsRead = $markAsRead; | ||
132 | |||
133 | return $this; | ||
134 | } | ||
135 | |||
136 | /** | ||
124 | * @param $entries | 137 | * @param $entries |
125 | */ | 138 | */ |
126 | protected function parseEntries($entries) | 139 | protected function parseEntries($entries) |
@@ -160,7 +173,7 @@ class WallabagV1Import implements ImportInterface | |||
160 | ); | 173 | ); |
161 | } | 174 | } |
162 | 175 | ||
163 | $entry->setArchived($importedEntry['is_read']); | 176 | $entry->setArchived($importedEntry['is_read'] || $this->markAsRead); |
164 | $entry->setStarred($importedEntry['is_fav']); | 177 | $entry->setStarred($importedEntry['is_fav']); |
165 | 178 | ||
166 | $this->em->persist($entry); | 179 | $this->em->persist($entry); |
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php index 7125eabc..c4bac561 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php | |||
@@ -51,7 +51,7 @@ class WallabagV2Import extends WallabagV1Import implements ImportInterface | |||
51 | $entry = new Entry($this->user); | 51 | $entry = new Entry($this->user); |
52 | $entry->setUrl($importedEntry['url']); | 52 | $entry->setUrl($importedEntry['url']); |
53 | $entry->setTitle($importedEntry['title']); | 53 | $entry->setTitle($importedEntry['title']); |
54 | $entry->setArchived($importedEntry['is_archived']); | 54 | $entry->setArchived($importedEntry['is_archived'] || $this->markAsRead); |
55 | $entry->setStarred($importedEntry['is_starred']); | 55 | $entry->setStarred($importedEntry['is_starred']); |
56 | $entry->setContent($importedEntry['content']); | 56 | $entry->setContent($importedEntry['content']); |
57 | $entry->setReadingTime($importedEntry['reading_time']); | 57 | $entry->setReadingTime($importedEntry['reading_time']); |