]>
Commit | Line | Data |
---|---|---|
b1d05721 JB |
1 | <?php |
2 | ||
3 | namespace Wallabag\ImportBundle\Import; | |
4 | ||
b787a775 | 5 | class WallabagV1Import extends WallabagImport |
b1d05721 | 6 | { |
704803e1 JC |
7 | protected $fetchingErrorMessage; |
8 | protected $fetchingErrorMessageTitle; | |
9 | ||
d5c2cc54 | 10 | public function __construct($em, $contentProxy, $tagsAssigner, $eventDispatcher, $fetchingErrorMessageTitle, $fetchingErrorMessage) |
704803e1 JC |
11 | { |
12 | $this->fetchingErrorMessageTitle = $fetchingErrorMessageTitle; | |
13 | $this->fetchingErrorMessage = $fetchingErrorMessage; | |
14 | ||
d5c2cc54 | 15 | parent::__construct($em, $contentProxy, $tagsAssigner, $eventDispatcher); |
704803e1 JC |
16 | } |
17 | ||
b1d05721 JB |
18 | /** |
19 | * {@inheritdoc} | |
20 | */ | |
21 | public function getName() | |
22 | { | |
d1af8ad4 | 23 | return 'wallabag v1'; |
b1d05721 JB |
24 | } |
25 | ||
7019c7cf JB |
26 | /** |
27 | * {@inheritdoc} | |
28 | */ | |
29 | public function getUrl() | |
30 | { | |
31 | return 'import_wallabag_v1'; | |
32 | } | |
33 | ||
b1d05721 JB |
34 | /** |
35 | * {@inheritdoc} | |
36 | */ | |
37 | public function getDescription() | |
38 | { | |
0d42217e | 39 | return 'import.wallabag_v1.description'; |
b1d05721 JB |
40 | } |
41 | ||
42 | /** | |
43 | * {@inheritdoc} | |
44 | */ | |
c98db1b6 | 45 | protected function prepareEntry($entry = []) |
b787a775 JB |
46 | { |
47 | $data = [ | |
48 | 'title' => $entry['title'], | |
49 | 'html' => $entry['content'], | |
50 | 'url' => $entry['url'], | |
c98db1b6 | 51 | 'is_archived' => $entry['is_read'] || $this->markAsRead, |
b787a775 JB |
52 | 'is_starred' => $entry['is_fav'], |
53 | 'tags' => '', | |
6d65c0a8 | 54 | 'created_at' => '', |
b1d05721 | 55 | ]; |
b1d05721 | 56 | |
704803e1 JC |
57 | // In case of a bad fetch in v1, replace title and content with v2 error strings |
58 | // If fetching fails again, they will get this instead of the v1 strings | |
2a1ceb67 | 59 | if (\in_array($entry['title'], $this->untitled, true)) { |
704803e1 JC |
60 | $data['title'] = $this->fetchingErrorMessageTitle; |
61 | $data['html'] = $this->fetchingErrorMessage; | |
b787a775 | 62 | } |
7019c7cf | 63 | |
3ef055ce | 64 | if (array_key_exists('tags', $entry) && '' !== $entry['tags']) { |
b787a775 | 65 | $data['tags'] = $entry['tags']; |
b1d05721 JB |
66 | } |
67 | ||
b787a775 | 68 | return $data; |
b1d05721 | 69 | } |
c98db1b6 | 70 | |
3849a9f3 JB |
71 | /** |
72 | * {@inheritdoc} | |
73 | */ | |
74 | protected function setEntryAsRead(array $importedEntry) | |
c98db1b6 | 75 | { |
3849a9f3 | 76 | $importedEntry['is_read'] = 1; |
c98db1b6 | 77 | |
3849a9f3 | 78 | return $importedEntry; |
c98db1b6 | 79 | } |
b1d05721 | 80 | } |