aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/BrowserImport.php
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2017-01-27 09:34:32 +0100
committerGitHub <noreply@github.com>2017-01-27 09:34:32 +0100
commit6fb06904ecde15b1b07d0a2af945338b416cf0e2 (patch)
treee76f3e8142399316ec5660fab8c646b2c34b8336 /src/Wallabag/ImportBundle/Import/BrowserImport.php
parent05fa529bcfde01be5d320cb532900d72cf4b0830 (diff)
parent78295b99dd1721c613f1ce52e2debbe6f6db7753 (diff)
downloadwallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.gz
wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.zst
wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.zip
Merge pull request #2416 from wallabag/2.2
wallabag 2.2.0
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index 2ca1683b..8bf7d92e 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -5,6 +5,7 @@ namespace Wallabag\ImportBundle\Import;
5use Wallabag\CoreBundle\Entity\Entry; 5use Wallabag\CoreBundle\Entity\Entry;
6use Wallabag\UserBundle\Entity\User; 6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Helper\ContentProxy; 7use Wallabag\CoreBundle\Helper\ContentProxy;
8use Wallabag\CoreBundle\Event\EntrySavedEvent;
8 9
9abstract class BrowserImport extends AbstractImport 10abstract class BrowserImport extends AbstractImport
10{ 11{
@@ -81,6 +82,7 @@ abstract class BrowserImport extends AbstractImport
81 protected function parseEntries($entries) 82 protected function parseEntries($entries)
82 { 83 {
83 $i = 1; 84 $i = 1;
85 $entryToBeFlushed = [];
84 86
85 foreach ($entries as $importedEntry) { 87 foreach ($entries as $importedEntry) {
86 if ((array) $importedEntry !== $importedEntry) { 88 if ((array) $importedEntry !== $importedEntry) {
@@ -93,14 +95,29 @@ abstract class BrowserImport extends AbstractImport
93 continue; 95 continue;
94 } 96 }
95 97
98 // @see AbstractImport
99 $entryToBeFlushed[] = $entry;
100
96 // flush every 20 entries 101 // flush every 20 entries
97 if (($i % 20) === 0) { 102 if (($i % 20) === 0) {
98 $this->em->flush(); 103 $this->em->flush();
104
105 foreach ($entryToBeFlushed as $entry) {
106 $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
107 }
108
109 $entryToBeFlushed = [];
99 } 110 }
100 ++$i; 111 ++$i;
101 } 112 }
102 113
103 $this->em->flush(); 114 $this->em->flush();
115
116 if (!empty($entryToBeFlushed)) {
117 foreach ($entryToBeFlushed as $entry) {
118 $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
119 }
120 }
104 } 121 }
105 122
106 /** 123 /**