3 namespace Wallabag\ImportBundle\Import
;
5 use Wallabag\CoreBundle\Entity\Entry
;
7 class WallabagV2Import
extends WallabagV1Import
implements ImportInterface
12 public function getName()
20 public function getUrl()
22 return 'import_wallabag_v2';
28 public function getDescription()
30 return 'This importer will import all your wallabag v2 articles. Go to All articles, then, on the export sidebar, click on "JSON". You will have a "All articles.json" file.';
36 protected function parseEntries($entries)
40 foreach ($entries as $importedEntry) {
41 $existingEntry = $this->em
42 ->getRepository('WallabagCoreBundle:Entry')
43 ->findByUrlAndUserId($importedEntry['url'], $this->user
->getId());
45 if (false !== $existingEntry) {
46 ++
$this->skippedEntries
;
50 // @see ContentProxy->updateEntry
51 $entry = new Entry($this->user
);
52 $entry->setUrl($importedEntry['url']);
53 $entry->setTitle($importedEntry['title']);
54 $entry->setArchived($importedEntry['is_archived'] || $this->markAsRead
);
55 $entry->setStarred($importedEntry['is_starred']);
56 $entry->setContent($importedEntry['content']);
57 $entry->setReadingTime($importedEntry['reading_time']);
58 $entry->setDomainName($importedEntry['domain_name']);
59 if (isset($importedEntry['mimetype'])) {
60 $entry->setMimetype($importedEntry['mimetype']);
62 if (isset($importedEntry['language'])) {
63 $entry->setLanguage($importedEntry['language']);
65 if (isset($importedEntry['preview_picture'])) {
66 $entry->setPreviewPicture($importedEntry['preview_picture']);
69 $this->em
->persist($entry);
70 ++
$this->importedEntries
;
72 // flush every 20 entries
73 if (($i %
20) === 0) {