Files
wallabag/src/Wallabag/ImportBundle/Import/WallabagV1Import.php

76 lines
1.7 KiB
PHP
Raw Normal View History

2015-12-30 13:26:30 +01:00
<?php
namespace Wallabag\ImportBundle\Import;
class WallabagV1Import extends WallabagImport
2015-12-30 13:26:30 +01:00
{
/**
* {@inheritdoc}
*/
public function getName()
{
2016-01-05 22:38:09 +01:00
return 'wallabag v1';
2015-12-30 13:26:30 +01:00
}
/**
* {@inheritdoc}
*/
public function getUrl()
{
return 'import_wallabag_v1';
}
2015-12-30 13:26:30 +01:00
/**
* {@inheritdoc}
*/
public function getDescription()
{
return 'import.wallabag_v1.description';
2015-12-30 13:26:30 +01:00
}
/**
* {@inheritdoc}
*/
2016-09-04 21:49:21 +02:00
protected function prepareEntry($entry = [])
{
$data = [
'title' => $entry['title'],
'html' => $entry['content'],
'url' => $entry['url'],
'content_type' => '',
'language' => '',
2016-09-04 21:49:21 +02:00
'is_archived' => $entry['is_read'] || $this->markAsRead,
'is_starred' => $entry['is_fav'],
'tags' => '',
2015-12-30 13:26:30 +01:00
];
// force content to be refreshed in case on bad fetch in the v1 installation
if (in_array($entry['title'], $this->untitled)) {
$data['title'] = '';
$data['html'] = '';
}
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
$data['tags'] = $entry['tags'];
2015-12-30 13:26:30 +01:00
}
return $data;
2015-12-30 13:26:30 +01:00
}
2016-09-04 21:49:21 +02:00
protected function parseEntriesForProducer($entries)
{
foreach ($entries as $importedEntry) {
// set userId for the producer (it won't know which user is connected)
$importedEntry['userId'] = $this->user->getId();
if ($this->markAsRead) {
$importedEntry['is_read'] = 1;
}
++$this->importedEntries;
$this->producer->publish(json_encode($importedEntry));
}
}
2015-12-30 13:26:30 +01:00
}