aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/PocketImport.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-31 11:24:46 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-01-02 23:27:41 +0100
commit7019c7cf6c6af39c0f458769e20c3f9306477943 (patch)
tree12acceaa458cdf6d24367eba85f690265acddcdb /src/Wallabag/ImportBundle/Import/PocketImport.php
parentb1d05721cf37ab94ec1a6837fe79cf19474dd0ff (diff)
downloadwallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.tar.gz
wallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.tar.zst
wallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.zip
Add tagged services for import
- list services in /import - add url to import service - ImportBundle routing are now prefixed by /import - optimize flush in each import (flushing each 20 contents) - improve design of each import - add more tests
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/PocketImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index aeccc7bd..b1c5bb00 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -48,9 +48,17 @@ class PocketImport implements ImportInterface
48 /** 48 /**
49 * {@inheritdoc} 49 * {@inheritdoc}
50 */ 50 */
51 public function getUrl()
52 {
53 return 'import_pocket';
54 }
55
56 /**
57 * {@inheritdoc}
58 */
51 public function getDescription() 59 public function getDescription()
52 { 60 {
53 return 'This importer will import all your <a href="https://getpocket.com">Pocket</a> data.'; 61 return 'This importer will import all your <a href="https://getpocket.com">Pocket</a> data. Pocket doesn\'t allow us to retrieve content from their service, so the readable content of each article will be re-fetched by Wallabag.';
54 } 62 }
55 63
56 /** 64 /**
@@ -196,6 +204,8 @@ class PocketImport implements ImportInterface
196 */ 204 */
197 private function parseEntries($entries) 205 private function parseEntries($entries)
198 { 206 {
207 $i = 1;
208
199 foreach ($entries as $pocketEntry) { 209 foreach ($entries as $pocketEntry) {
200 $url = isset($pocketEntry['resolved_url']) && $pocketEntry['resolved_url'] != '' ? $pocketEntry['resolved_url'] : $pocketEntry['given_url']; 210 $url = isset($pocketEntry['resolved_url']) && $pocketEntry['resolved_url'] != '' ? $pocketEntry['resolved_url'] : $pocketEntry['given_url'];
201 211
@@ -241,6 +251,12 @@ class PocketImport implements ImportInterface
241 251
242 $this->em->persist($entry); 252 $this->em->persist($entry);
243 ++$this->importedEntries; 253 ++$this->importedEntries;
254
255 // flush every 20 entries
256 if (($i % 20) === 0) {
257 $em->flush();
258 }
259 ++$i;
244 } 260 }
245 261
246 $this->em->flush(); 262 $this->em->flush();