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.
return $entry;
}
- /**
- * {@inheritdoc}
- */
- protected function prepareEntry(array $entry = [])
- {
- $url = array_key_exists('uri', $entry) ? $entry['uri'] : $entry['url'];
- $date = array_key_exists('date_added', $entry) ? $entry['date_added'] : $entry['dateAdded'];
- $title = array_key_exists('name', $entry) ? $entry['name'] : $entry['title'];
-
- if (16 === strlen($date)) {
- // firefox ...
- $date = (int) ceil($date / 1000000);
- } else if (17 === strlen($date)) {
- // chrome ...
- $date = (int) ceil($date / 10000000);
- } else {
- $date = '';
- }
-
- $data = [
- 'title' => $title,
- 'html' => '',
- 'url' => $url,
- 'is_archived' => $this->markAsRead,
- 'tags' => '',
- 'created_at' => $date,
- ];
-
- if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
- $data['tags'] = $entry['tags'];
- }
-
- return $data;
- }
-
/**
* {@inheritdoc}
*/
{
return 'import.chrome.description';
}
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function prepareEntry(array $entry = [])
+ {
+ $data = [
+ 'title' => $entry['name'],
+ 'html' => '',
+ 'url' => $entry['url'],
+ 'is_archived' => $this->markAsRead,
+ 'tags' => '',
+ 'created_at' => substr($entry['date_added'], 0, 10),
+ ];
+
+ if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
+ $data['tags'] = $entry['tags'];
+ }
+
+ return $data;
+ }
}
{
return 'import.firefox.description';
}
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function prepareEntry(array $entry = [])
+ {
+ $data = [
+ 'title' => $entry['title'],
+ 'html' => '',
+ 'url' => $entry['uri'],
+ 'is_archived' => $this->markAsRead,
+ 'tags' => '',
+ 'created_at' => substr($entry['dateAdded'], 0, 10),
+ ];
+
+ if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
+ $data['tags'] = $entry['tags'];
+ }
+
+ return $data;
+ }
}