]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/ImportBundle/Import/WallabagV2Import.php
Convert other imports to Rabbit
[github/wallabag/wallabag.git] / src / Wallabag / ImportBundle / Import / WallabagV2Import.php
CommitLineData
6785f4aa
NL
1<?php
2
3namespace Wallabag\ImportBundle\Import;
4
b787a775 5class WallabagV2Import extends WallabagImport
6785f4aa
NL
6{
7 /**
8 * {@inheritdoc}
9 */
10 public function getName()
11 {
12 return 'wallabag v2';
13 }
14
15 /**
16 * {@inheritdoc}
17 */
18 public function getUrl()
19 {
20 return 'import_wallabag_v2';
21 }
22
23 /**
24 * {@inheritdoc}
25 */
26 public function getDescription()
27 {
0d42217e 28 return 'import.wallabag_v2.description';
6785f4aa
NL
29 }
30
31 /**
b787a775 32 * {@inheritdoc}
6785f4aa 33 */
c98db1b6 34 protected function prepareEntry($entry = [])
6785f4aa 35 {
b787a775
JB
36 return [
37 'html' => $entry['content'],
38 'content_type' => $entry['mimetype'],
c98db1b6 39 'is_archived' => ($entry['is_archived'] || $this->markAsRead),
b787a775 40 ] + $entry;
6785f4aa 41 }
c98db1b6
JB
42
43 protected function parseEntriesForProducer($entries)
44 {
45 foreach ($entries as $importedEntry) {
46 // set userId for the producer (it won't know which user is connected)
47 $importedEntry['userId'] = $this->user->getId();
48
49 if ($this->markAsRead) {
50 $importedEntry['is_archived'] = 1;
51 }
52
53 ++$this->importedEntries;
54
55 $this->producer->publish(json_encode($importedEntry));
56 }
57 }
6785f4aa 58}