]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ImportBundle/Import/FirefoxImport.php
Validate imported entry to avoid error on import
[github/wallabag/wallabag.git] / src / Wallabag / ImportBundle / Import / FirefoxImport.php
index 1a0b1154306d1a6de868995b21da1991236f807f..8999e3f3932240accb4096b519af13a31230bdbc 100644 (file)
@@ -29,4 +29,38 @@ class FirefoxImport extends BrowserImport
     {
         return 'import.firefox.description';
     }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function validateEntry(array $importedEntry)
+    {
+        if (empty($importedEntry['uri'])) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function prepareEntry(array $entry = [])
+    {
+        $data = [
+            'title' => $entry['title'],
+            'html' => false,
+            'url' => $entry['uri'],
+            'is_archived' => (int) $this->markAsRead,
+            'is_starred' => false,
+            'tags' => '',
+            'created_at' => substr($entry['dateAdded'], 0, 10),
+        ];
+
+        if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
+            $data['tags'] = $entry['tags'];
+        }
+
+        return $data;
+    }
 }