]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/ImportBundle/Import/WallabagV1Import.php
Retrieve all items from Pocket
[github/wallabag/wallabag.git] / src / Wallabag / ImportBundle / Import / WallabagV1Import.php
CommitLineData
b1d05721
JB
1<?php
2
3namespace Wallabag\ImportBundle\Import;
4
b787a775 5class WallabagV1Import extends WallabagImport
b1d05721 6{
b1d05721
JB
7 /**
8 * {@inheritdoc}
9 */
10 public function getName()
11 {
d1af8ad4 12 return 'wallabag v1';
b1d05721
JB
13 }
14
7019c7cf
JB
15 /**
16 * {@inheritdoc}
17 */
18 public function getUrl()
19 {
20 return 'import_wallabag_v1';
21 }
22
b1d05721
JB
23 /**
24 * {@inheritdoc}
25 */
26 public function getDescription()
27 {
0d42217e 28 return 'import.wallabag_v1.description';
b1d05721
JB
29 }
30
31 /**
32 * {@inheritdoc}
33 */
c98db1b6 34 protected function prepareEntry($entry = [])
b787a775
JB
35 {
36 $data = [
37 'title' => $entry['title'],
38 'html' => $entry['content'],
39 'url' => $entry['url'],
40 'content_type' => '',
41 'language' => '',
c98db1b6 42 'is_archived' => $entry['is_read'] || $this->markAsRead,
b787a775
JB
43 'is_starred' => $entry['is_fav'],
44 'tags' => '',
b1d05721 45 ];
b1d05721 46
b787a775
JB
47 // force content to be refreshed in case on bad fetch in the v1 installation
48 if (in_array($entry['title'], $this->untitled)) {
49 $data['title'] = '';
50 $data['html'] = '';
51 }
7019c7cf 52
b787a775
JB
53 if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
54 $data['tags'] = $entry['tags'];
b1d05721
JB
55 }
56
b787a775 57 return $data;
b1d05721 58 }
c98db1b6
JB
59
60 protected function parseEntriesForProducer($entries)
61 {
62 foreach ($entries as $importedEntry) {
63 // set userId for the producer (it won't know which user is connected)
64 $importedEntry['userId'] = $this->user->getId();
65
66 if ($this->markAsRead) {
67 $importedEntry['is_read'] = 1;
68 }
69
70 ++$this->importedEntries;
71
72 $this->producer->publish(json_encode($importedEntry));
73 }
74 }
b1d05721 75}