namespace Wallabag\ImportBundle\Import;
+use Doctrine\ORM\EntityManager;
+use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
-use Doctrine\ORM\EntityManager;
-use Wallabag\CoreBundle\Helper\ContentProxy;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
+use Wallabag\CoreBundle\Event\EntrySavedEvent;
+use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Helper\TagsAssigner;
use Wallabag\UserBundle\Entity\User;
-use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Wallabag\CoreBundle\Event\EntrySavedEvent;
abstract class AbstractImport implements ImportInterface
{
protected $producer;
protected $user;
protected $markAsRead;
- protected $disableContentUpdate;
+ protected $disableContentUpdate = false;
protected $skippedEntries = 0;
protected $importedEntries = 0;
protected $queuedEntries = 0;
/**
* Set whether articles should be fetched for updated content.
*
- * @param bool $markAsRead
+ * @param bool $disableContentUpdate
*/
public function setDisableContentUpdate($disableContentUpdate)
{
}
/**
- * Get whether articles should be fetched for updated content.
+ * {@inheritdoc}
*/
- public function getDisableContentUpdate()
+ public function getSummary()
{
- return $this->disableContentUpdate;
+ return [
+ 'skipped' => $this->skippedEntries,
+ 'imported' => $this->importedEntries,
+ 'queued' => $this->queuedEntries,
+ ];
}
+ /**
+ * Parse one entry.
+ *
+ * @param array $importedEntry
+ *
+ * @return Entry
+ */
+ abstract public function parseEntry(array $importedEntry);
/**
* Fetch content from the ContentProxy (using graby).
protected function fetchContent(Entry $entry, $url, array $content = [])
{
try {
- $this->contentProxy->importEntry($entry, $content, $this->disableContentUpdate);
+ $this->contentProxy->updateEntry($entry, $url, $content, $this->disableContentUpdate);
} catch (\Exception $e) {
$this->logger->error('Error trying to import an entry.', [
- 'entry_url' => $content['url'],
+ 'entry_url' => $url,
'error_msg' => $e->getMessage(),
]);
}
}
}
- /**
- * {@inheritdoc}
- */
- public function getSummary()
- {
- return [
- 'skipped' => $this->skippedEntries,
- 'imported' => $this->importedEntries,
- 'queued' => $this->queuedEntries,
- ];
- }
-
- /**
- * Parse one entry.
- *
- * @param array $importedEntry
- *
- * @return Entry
- */
- abstract public function parseEntry(array $importedEntry);
-
/**
* Set current imported entry to archived / read.
* Implementation is different accross all imports.