Skip to content

Commit 8238c5f

Browse files
committed
Merge pull request #8 from yxie/master
This patch will reduce the TranslationImport command's running time from 45+ mins to 1.5 mins.
2 parents 34d301e + 0abfd28 commit 8238c5f

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

Command/ImportCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ function ($translation) use ($locale) {
151151
}
152152
}
153153

154+
$storage->flushAll();
155+
154156
$this->output->writeln('<info>DONE</info>');
155157
}
156158
}

Storage/AbstractStorage.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,19 @@ public function deleteTranslation($id)
102102
public function persist($entity)
103103
{
104104
$this->manager->persist($entity);
105-
$this->manager->flush();
106105

107106
return $entity;
108107
}
109108

109+
/**
110+
* {@inheritdoc}
111+
*/
112+
public function flushAll()
113+
{
114+
$this->manager->flush();
115+
$this->manager->clear();
116+
}
117+
110118
/**
111119
* Delete an entity based on its identifier.
112120
*
@@ -151,4 +159,4 @@ abstract protected function getEntryClassName();
151159
* @return string
152160
*/
153161
abstract protected function getTranslationClassName();
154-
}
162+
}

Storage/StorageInterface.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,9 @@ public function deleteTranslation($id);
104104
* @return object
105105
*/
106106
public function persist($entity);
107-
}
107+
108+
/**
109+
* Flushes all persisted entities, and clear the object manager
110+
*/
111+
public function flushAll();
112+
}

0 commit comments

Comments
 (0)