Skip to content

Commit

Permalink
Merge pull request #3 from AymenMech/fix/multiple_flush_causing_latency
Browse files Browse the repository at this point in the history
Fix - Multiple flush causing latency
  • Loading branch information
hmonglee authored Sep 9, 2021
2 parents 33bda7c + a571047 commit e446d62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function import(MessageCatalogueInterface $catalogue, array $options = []
$message = new Message($key, $domain, $locale, $translation);
$this->create($message);
}
$this->manager->flush();
}
}
}
7 changes: 5 additions & 2 deletions src/Service/TranslationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function createTranslation(MessageInterface $message)
->setStatus($message->getKey() === $message->getTranslation() ? Translation::STATUS_DRAFT : Translation::STATUS_PUBLISHED);

$this->entityManager->persist($translation);
$this->entityManager->flush();
}

/**
Expand All @@ -100,7 +99,6 @@ public function updateTranslation(MessageInterface $message)
}

$translation->setTranslation($message->getTranslation());
$this->entityManager->flush();
}

/**
Expand Down Expand Up @@ -136,6 +134,11 @@ private function findOneBy($locale, $domain, $key)
]);
}

public function flush(): void
{
$this->entityManager->flush();
}

/**
* @return ObjectRepository
*/
Expand Down

0 comments on commit e446d62

Please sign in to comment.