From 5559097e21c23326de0e15c796e463291a03e17f Mon Sep 17 00:00:00 2001 From: Yuan Xie Date: Tue, 12 Mar 2013 17:20:49 -0400 Subject: [PATCH] 1) Fixing issue that entity aren't persisted; 2) further optimize performance; --- Command/ImportCommand.php | 3 ++- Controller/EditorController.php | 6 ++++++ Storage/AbstractStorage.php | 9 ++++++++- Storage/StorageInterface.php | 9 +++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Command/ImportCommand.php b/Command/ImportCommand.php index d42b112..cbd8cb9 100755 --- a/Command/ImportCommand.php +++ b/Command/ImportCommand.php @@ -151,7 +151,8 @@ function ($translation) use ($locale) { } } - $storage->flushAll(); + $storage->flush(); + $storage->clear(); $this->output->writeln('DONE'); } diff --git a/Controller/EditorController.php b/Controller/EditorController.php index 3695528..4c34055 100755 --- a/Controller/EditorController.php +++ b/Controller/EditorController.php @@ -136,6 +136,8 @@ public function addTranslationAction() $storageService->createTranslation($locale, $entry, $translationValue); } + $storageService->flush(); + // Return reponse according to request type if ( ! $request->isXmlHttpRequest()) { return new RedirectResponse($this->generateUrl('sg_localeditor_index')); @@ -183,6 +185,8 @@ public function updateTranslationAction() $storageService->createTranslation($locale, $entry, $value); } + $storageService->flush(); + $result = array( 'result' => true, 'message' => 'Translation updated successfully.' @@ -253,6 +257,8 @@ public function addLocaleAction() // Create new Locale $storageService->createLocale($language, $country); + $storageService->flush(); + $result = array( 'result' => true, 'message' => 'New locale added successfully. Reload list for completion.' diff --git a/Storage/AbstractStorage.php b/Storage/AbstractStorage.php index 5a2fcd1..df77dbf 100755 --- a/Storage/AbstractStorage.php +++ b/Storage/AbstractStorage.php @@ -109,9 +109,16 @@ public function persist($entity) /** * {@inheritdoc} */ - public function flushAll() + public function flush() { $this->manager->flush(); + } + + /** + * {@inheritdoc} + */ + public function clear() + { $this->manager->clear(); } diff --git a/Storage/StorageInterface.php b/Storage/StorageInterface.php index 9f4a275..8d0c6ec 100755 --- a/Storage/StorageInterface.php +++ b/Storage/StorageInterface.php @@ -106,7 +106,12 @@ public function deleteTranslation($id); public function persist($entity); /** - * Flushes all persisted entities, and clear the object manager + * Flushes all persisted entities */ - public function flushAll(); + public function flush(); + + /** + * Clear all managed entities in the object manager + */ + public function clear(); }