Skip to content

Commit

Permalink
1) Fixing issue that entity aren't persisted; 2) further optimize per…
Browse files Browse the repository at this point in the history
…formance;
  • Loading branch information
Yuan Xie committed Mar 12, 2013
1 parent 284abb3 commit 5559097
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Command/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ function ($translation) use ($locale) {
}
}

$storage->flushAll();
$storage->flush();
$storage->clear();

$this->output->writeln('<info>DONE</info>');
}
Expand Down
6 changes: 6 additions & 0 deletions Controller/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -183,6 +185,8 @@ public function updateTranslationAction()
$storageService->createTranslation($locale, $entry, $value);
}

$storageService->flush();

$result = array(
'result' => true,
'message' => 'Translation updated successfully.'
Expand Down Expand Up @@ -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.'
Expand Down
9 changes: 8 additions & 1 deletion Storage/AbstractStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
9 changes: 7 additions & 2 deletions Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 5559097

Please sign in to comment.