forked from symfony/symfony
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DoctrineBundle] split Registry::getEntityManager() in two methods
Resetting an entity manager has a lot of consequences and the developer should be aware of that. So, instead of implicitly reset an entity manager when it is closed, the developer should reset it by hand if he thinks that this is possible: $em = $this->get('registry')->getEntityManager(); $em->getConnection()->beginTransaction(); // suspend auto-commit try { //... do some work } catch (Exception $e) { $em->getConnection()->rollback(); $em->close(); $this->get('registry')->resetEntityManager(); } // you will get a new one $em = $this->get('registry')->getEntityManager();
- Loading branch information
Showing
1 changed file
with
31 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters