]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ImportBundle/Import/PocketImport.php
Merge remote-tracking branch 'origin/master' into 2.3
[github/wallabag/wallabag.git] / src / Wallabag / ImportBundle / Import / PocketImport.php
index 1bf22d6874f8f2ec24f1b8d03d163fb559562186..c1d5b6da0518c33bef64a621336406c1679ad716 100644 (file)
@@ -2,12 +2,9 @@
 
 namespace Wallabag\ImportBundle\Import;
 
-use Psr\Log\NullLogger;
-use Doctrine\ORM\EntityManager;
 use GuzzleHttp\Client;
 use GuzzleHttp\Exception\RequestException;
 use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\CoreBundle\Helper\ContentProxy;
 
 class PocketImport extends AbstractImport
 {
@@ -16,13 +13,6 @@ class PocketImport extends AbstractImport
 
     const NB_ELEMENTS = 5000;
 
-    public function __construct(EntityManager $em, ContentProxy $contentProxy)
-    {
-        $this->em = $em;
-        $this->contentProxy = $contentProxy;
-        $this->logger = new NullLogger();
-    }
-
     /**
      * Only used for test purpose.
      *
@@ -199,24 +189,16 @@ class PocketImport extends AbstractImport
         }
 
         $entry = new Entry($this->user);
-        $entry = $this->fetchContent($entry, $url);
+        $entry->setUrl($url);
 
-        // jump to next entry in case of problem while getting content
-        if (false === $entry) {
-            ++$this->skippedEntries;
-
-            return;
-        }
+        // update entry with content (in case fetching failed, the given entry will be return)
+        $this->fetchContent($entry, $url);
 
         // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
-        if ($importedEntry['status'] == 1 || $this->markAsRead) {
-            $entry->setArchived(true);
-        }
+        $entry->setArchived($importedEntry['status'] == 1 || $this->markAsRead);
 
         // 0 or 1 - 1 If the item is starred
-        if ($importedEntry['favorite'] == 1) {
-            $entry->setStarred(true);
-        }
+        $entry->setStarred($importedEntry['favorite'] == 1);
 
         $title = 'Untitled';
         if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') {
@@ -226,7 +208,6 @@ class PocketImport extends AbstractImport
         }
 
         $entry->setTitle($title);
-        $entry->setUrl($url);
 
         // 0, 1, or 2 - 1 if the item has images in it - 2 if the item is an image
         if (isset($importedEntry['has_image']) && $importedEntry['has_image'] > 0 && isset($importedEntry['images'][1])) {
@@ -234,9 +215,10 @@ class PocketImport extends AbstractImport
         }
 
         if (isset($importedEntry['tags']) && !empty($importedEntry['tags'])) {
-            $this->contentProxy->assignTagsToEntry(
+            $this->tagsAssigner->assignTagsToEntry(
                 $entry,
-                array_keys($importedEntry['tags'])
+                array_keys($importedEntry['tags']),
+                $this->em->getUnitOfWork()->getScheduledEntityInsertions()
             );
         }