aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/PocketImport.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/PocketImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index 33093480..dddb87f4 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -5,15 +5,13 @@ namespace Wallabag\ImportBundle\Import;
5use GuzzleHttp\Client; 5use GuzzleHttp\Client;
6use GuzzleHttp\Exception\RequestException; 6use GuzzleHttp\Exception\RequestException;
7use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Helper\ContentProxy;
9 8
10class PocketImport extends AbstractImport 9class PocketImport extends AbstractImport
11{ 10{
11 const NB_ELEMENTS = 5000;
12 private $client; 12 private $client;
13 private $accessToken; 13 private $accessToken;
14 14
15 const NB_ELEMENTS = 5000;
16
17 /** 15 /**
18 * Only used for test purpose. 16 * Only used for test purpose.
19 * 17 *
@@ -151,7 +149,7 @@ class PocketImport extends AbstractImport
151 // - first call get 5k offset 0 149 // - first call get 5k offset 0
152 // - second call get 5k offset 5k 150 // - second call get 5k offset 5k
153 // - and so on 151 // - and so on
154 if (count($entries['list']) === self::NB_ELEMENTS) { 152 if (self::NB_ELEMENTS === count($entries['list'])) {
155 ++$run; 153 ++$run;
156 154
157 return $this->import(self::NB_ELEMENTS * $run); 155 return $this->import(self::NB_ELEMENTS * $run);
@@ -177,7 +175,7 @@ class PocketImport extends AbstractImport
177 */ 175 */
178 public function parseEntry(array $importedEntry) 176 public function parseEntry(array $importedEntry)
179 { 177 {
180 $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url']; 178 $url = isset($importedEntry['resolved_url']) && '' !== $importedEntry['resolved_url'] ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
181 179
182 $existingEntry = $this->em 180 $existingEntry = $this->em
183 ->getRepository('WallabagCoreBundle:Entry') 181 ->getRepository('WallabagCoreBundle:Entry')
@@ -193,18 +191,18 @@ class PocketImport extends AbstractImport
193 $entry->setUrl($url); 191 $entry->setUrl($url);
194 192
195 // update entry with content (in case fetching failed, the given entry will be return) 193 // update entry with content (in case fetching failed, the given entry will be return)
196 $entry = $this->fetchContent($entry, $url); 194 $this->fetchContent($entry, $url);
197 195
198 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted 196 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
199 $entry->setArchived($importedEntry['status'] == 1 || $this->markAsRead); 197 $entry->setArchived(1 === $importedEntry['status'] || $this->markAsRead);
200 198
201 // 0 or 1 - 1 If the item is starred 199 // 0 or 1 - 1 If the item is starred
202 $entry->setStarred($importedEntry['favorite'] == 1); 200 $entry->setStarred(1 === $importedEntry['favorite']);
203 201
204 $title = 'Untitled'; 202 $title = 'Untitled';
205 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') { 203 if (isset($importedEntry['resolved_title']) && '' !== $importedEntry['resolved_title']) {
206 $title = $importedEntry['resolved_title']; 204 $title = $importedEntry['resolved_title'];
207 } elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] != '') { 205 } elseif (isset($importedEntry['given_title']) && '' !== $importedEntry['given_title']) {
208 $title = $importedEntry['given_title']; 206 $title = $importedEntry['given_title'];
209 } 207 }
210 208
@@ -216,7 +214,7 @@ class PocketImport extends AbstractImport
216 } 214 }
217 215
218 if (isset($importedEntry['tags']) && !empty($importedEntry['tags'])) { 216 if (isset($importedEntry['tags']) && !empty($importedEntry['tags'])) {
219 $this->contentProxy->assignTagsToEntry( 217 $this->tagsAssigner->assignTagsToEntry(
220 $entry, 218 $entry,
221 array_keys($importedEntry['tags']), 219 array_keys($importedEntry['tags']),
222 $this->em->getUnitOfWork()->getScheduledEntityInsertions() 220 $this->em->getUnitOfWork()->getScheduledEntityInsertions()