diff options
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/AbstractImport.php')
-rw-r--r-- | src/Wallabag/ImportBundle/Import/AbstractImport.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php index a61388c0..9b624296 100644 --- a/src/Wallabag/ImportBundle/Import/AbstractImport.php +++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php | |||
@@ -24,6 +24,7 @@ abstract class AbstractImport implements ImportInterface | |||
24 | protected $producer; | 24 | protected $producer; |
25 | protected $user; | 25 | protected $user; |
26 | protected $markAsRead; | 26 | protected $markAsRead; |
27 | protected $disableContentUpdate = false; | ||
27 | protected $skippedEntries = 0; | 28 | protected $skippedEntries = 0; |
28 | protected $importedEntries = 0; | 29 | protected $importedEntries = 0; |
29 | protected $queuedEntries = 0; | 30 | protected $queuedEntries = 0; |
@@ -85,21 +86,34 @@ abstract class AbstractImport implements ImportInterface | |||
85 | } | 86 | } |
86 | 87 | ||
87 | /** | 88 | /** |
89 | * Set whether articles should be fetched for updated content. | ||
90 | * | ||
91 | * @param bool $disableContentUpdate | ||
92 | */ | ||
93 | public function setDisableContentUpdate($disableContentUpdate) | ||
94 | { | ||
95 | $this->disableContentUpdate = $disableContentUpdate; | ||
96 | |||
97 | return $this; | ||
98 | } | ||
99 | |||
100 | /** | ||
88 | * Fetch content from the ContentProxy (using graby). | 101 | * Fetch content from the ContentProxy (using graby). |
89 | * If it fails return the given entry to be saved in all case (to avoid user to loose the content). | 102 | * If it fails return the given entry to be saved in all case (to avoid user to loose the content). |
90 | * | 103 | * |
91 | * @param Entry $entry Entry to update | 104 | * @param Entry $entry Entry to update |
92 | * @param string $url Url to grab content for | 105 | * @param string $url Url to grab content for |
93 | * @param array $content An array with AT LEAST keys title, html, url, language & content_type to skip the fetchContent from the url | 106 | * @param array $content An array with AT LEAST keys title, html, url, language & content_type to skip the fetchContent from the url |
94 | * | ||
95 | * @return Entry | ||
96 | */ | 107 | */ |
97 | protected function fetchContent(Entry $entry, $url, array $content = []) | 108 | protected function fetchContent(Entry $entry, $url, array $content = []) |
98 | { | 109 | { |
99 | try { | 110 | try { |
100 | return $this->contentProxy->updateEntry($entry, $url, $content); | 111 | $this->contentProxy->updateEntry($entry, $url, $content, $this->disableContentUpdate); |
101 | } catch (\Exception $e) { | 112 | } catch (\Exception $e) { |
102 | return $entry; | 113 | $this->logger->error('Error trying to import an entry.', [ |
114 | 'entry_url' => $url, | ||
115 | 'error_msg' => $e->getMessage(), | ||
116 | ]); | ||
103 | } | 117 | } |
104 | } | 118 | } |
105 | 119 | ||