X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FImportBundle%2FImport%2FPocketImport.php;h=798cfdaefe05cc0746340d8f21b2b8b38e2d616b;hb=33adf8dc915f4911fd454e98194c1b2323514d4a;hp=238ddbd1f71548b304a24489b095a0e98f0b6fd4;hpb=79d0e38e7ff975b2e0306d3dd96f57509fd84aef;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 238ddbd1..798cfdae 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -2,7 +2,6 @@ namespace Wallabag\ImportBundle\Import; -use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Doctrine\ORM\EntityManager; use GuzzleHttp\Client; @@ -12,12 +11,9 @@ use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Helper\ContentProxy; use Craue\ConfigBundle\Util\Config; -class PocketImport implements ImportInterface +class PocketImport extends AbstractImport { private $user; - private $em; - private $contentProxy; - private $logger; private $client; private $consumerKey; private $skippedEntries = 0; @@ -34,11 +30,6 @@ class PocketImport implements ImportInterface $this->logger = new NullLogger(); } - public function setLogger(LoggerInterface $logger) - { - $this->logger = $logger; - } - /** * {@inheritdoc} */ @@ -60,7 +51,7 @@ class PocketImport implements ImportInterface */ public function getDescription() { - return 'This importer will import all your Pocket 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.'; + return 'import.pocket.description'; } /** @@ -68,7 +59,7 @@ class PocketImport implements ImportInterface * * @param string $redirectUri Redirect url in case of error * - * @return string request_token for callback method + * @return string|false request_token for callback method */ public function getRequestToken($redirectUri) { @@ -139,7 +130,7 @@ class PocketImport implements ImportInterface /** * Get whether articles must be all marked as read. */ - public function getRead() + public function getMarkAsRead() { return $this->markAsRead; } @@ -219,14 +210,20 @@ class PocketImport implements ImportInterface } $entry = new Entry($this->user); - $entry = $this->contentProxy->updateEntry($entry, $url); + $entry = $this->fetchContent($entry, $url); + + // jump to next entry in case of problem while getting content + if (false === $entry) { + ++$this->skippedEntries; + continue; + } // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted if ($pocketEntry['status'] == 1 || $this->markAsRead) { $entry->setArchived(true); } - // 0 or 1 - 1 If the item is favorited + // 0 or 1 - 1 If the item is starred if ($pocketEntry['favorite'] == 1) { $entry->setStarred(true); } @@ -258,6 +255,7 @@ class PocketImport implements ImportInterface // flush every 20 entries if (($i % 20) === 0) { $this->em->flush(); + $this->em->clear($entry); } ++$i; }