]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/ImportBundle/Import/WallabagV1Import.php
Merge pull request #2879 from matteocoder/matteocoder-patch-1
[github/wallabag/wallabag.git] / src / Wallabag / ImportBundle / Import / WallabagV1Import.php
1 <?php
2
3 namespace Wallabag\ImportBundle\Import;
4
5 class WallabagV1Import extends WallabagImport
6 {
7 /**
8 * {@inheritdoc}
9 */
10 public function getName()
11 {
12 return 'wallabag v1';
13 }
14
15 /**
16 * {@inheritdoc}
17 */
18 public function getUrl()
19 {
20 return 'import_wallabag_v1';
21 }
22
23 /**
24 * {@inheritdoc}
25 */
26 public function getDescription()
27 {
28 return 'import.wallabag_v1.description';
29 }
30
31 /**
32 * {@inheritdoc}
33 */
34 protected function prepareEntry($entry = [])
35 {
36 $data = [
37 'title' => $entry['title'],
38 'html' => $entry['content'],
39 'url' => $entry['url'],
40 'is_archived' => $entry['is_read'] || $this->markAsRead,
41 'is_starred' => $entry['is_fav'],
42 'tags' => '',
43 'created_at' => '',
44 ];
45
46 // force content to be refreshed in case on bad fetch in the v1 installation
47 if (in_array($entry['title'], $this->untitled)) {
48 $data['title'] = '';
49 $data['html'] = '';
50 }
51
52 if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
53 $data['tags'] = $entry['tags'];
54 }
55
56 return $data;
57 }
58
59 /**
60 * {@inheritdoc}
61 */
62 protected function setEntryAsRead(array $importedEntry)
63 {
64 $importedEntry['is_read'] = 1;
65
66 return $importedEntry;
67 }
68 }