- $i = 1;
-
- foreach ($entries as $pocketEntry) {
- $url = isset($pocketEntry['resolved_url']) && $pocketEntry['resolved_url'] != '' ? $pocketEntry['resolved_url'] : $pocketEntry['given_url'];
-
- $existingEntry = $this->em
- ->getRepository('WallabagCoreBundle:Entry')
- ->findByUrlAndUserId($url, $this->user->getId());
-
- if (false !== $existingEntry) {
- ++$this->skippedEntries;
- continue;
- }
-
- $entry = new Entry($this->user);
- $entry = $this->contentProxy->updateEntry($entry, $url);
-
- // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
- if ($pocketEntry['status'] == 1) {
- $entry->setArchived(true);
- }
-
- // 0 or 1 - 1 If the item is favorited
- if ($pocketEntry['favorite'] == 1) {
- $entry->setStarred(true);
- }
-
- $title = 'Untitled';
- if (isset($pocketEntry['resolved_title']) && $pocketEntry['resolved_title'] != '') {
- $title = $pocketEntry['resolved_title'];
- } elseif (isset($pocketEntry['given_title']) && $pocketEntry['given_title'] != '') {
- $title = $pocketEntry['given_title'];
- }
-
- $entry->setTitle($title);
-
- // 0, 1, or 2 - 1 if the item has images in it - 2 if the item is an image
- if (isset($pocketEntry['has_image']) && $pocketEntry['has_image'] > 0 && isset($pocketEntry['images'][1])) {
- $entry->setPreviewPicture($pocketEntry['images'][1]['src']);
- }
-
- if (isset($pocketEntry['tags']) && !empty($pocketEntry['tags'])) {
- $this->contentProxy->assignTagsToEntry(
- $entry,
- array_keys($pocketEntry['tags'])
- );
- }
-
- $this->em->persist($entry);
- ++$this->importedEntries;
-
- // flush every 20 entries
- if (($i % 20) === 0) {
- $this->em->flush();
- }
- ++$i;
+ $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
+
+ $existingEntry = $this->em
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findByUrlAndUserId($url, $this->user->getId());
+
+ if (false !== $existingEntry) {
+ ++$this->skippedEntries;
+
+ return;