aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/BrowserImport.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-09-26 07:30:02 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-26 07:30:02 +0200
commit990adfb34c148e7cd28b9cb784cf2b7388caae8f (patch)
treef716810fa5f766bcdfa5af5bb9ba3b568c3517ca /src/Wallabag/ImportBundle/Import/BrowserImport.php
parent12d93e6896f2d99b6329b7979ee7b6d11e457c3a (diff)
downloadwallabag-990adfb34c148e7cd28b9cb784cf2b7388caae8f.tar.gz
wallabag-990adfb34c148e7cd28b9cb784cf2b7388caae8f.tar.zst
wallabag-990adfb34c148e7cd28b9cb784cf2b7388caae8f.zip
Move prepareEntry to dedicated place
Yeah first try was ugly, now each part are in the dedicated place. Also, the date is hardly truncated to 10 chars because Firefox date are 16 chars long and Chrome are 17 chars long. So instead of divised them by a huge number, I prefer to truncate them.
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php35
1 files changed, 0 insertions, 35 deletions
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index 68fa8bf8..e15443c4 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -196,41 +196,6 @@ abstract class BrowserImport extends AbstractImport
196 /** 196 /**
197 * {@inheritdoc} 197 * {@inheritdoc}
198 */ 198 */
199 protected function prepareEntry(array $entry = [])
200 {
201 $url = array_key_exists('uri', $entry) ? $entry['uri'] : $entry['url'];
202 $date = array_key_exists('date_added', $entry) ? $entry['date_added'] : $entry['dateAdded'];
203 $title = array_key_exists('name', $entry) ? $entry['name'] : $entry['title'];
204
205 if (16 === strlen($date)) {
206 // firefox ...
207 $date = (int) ceil($date / 1000000);
208 } else if (17 === strlen($date)) {
209 // chrome ...
210 $date = (int) ceil($date / 10000000);
211 } else {
212 $date = '';
213 }
214
215 $data = [
216 'title' => $title,
217 'html' => '',
218 'url' => $url,
219 'is_archived' => $this->markAsRead,
220 'tags' => '',
221 'created_at' => $date,
222 ];
223
224 if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
225 $data['tags'] = $entry['tags'];
226 }
227
228 return $data;
229 }
230
231 /**
232 * {@inheritdoc}
233 */
234 protected function setEntryAsRead(array $importedEntry) 199 protected function setEntryAsRead(array $importedEntry)
235 { 200 {
236 $importedEntry['is_archived'] = 1; 201 $importedEntry['is_archived'] = 1;