Revision: 187
http://sourceforge.net/p/beeframework/code/187
Author: m_plomer
Date: 2014-07-24 09:27:29 +0000 (Thu, 24 Jul 2014)
Log Message:
-----------
- Doctrine2: introduced transactional() convenience wrapper
Modified Paths:
--------------
trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php
trunk/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php
Modified: trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php
===================================================================
--- trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php 2014-07-23 18:12:43 UTC (rev 186)
+++ trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php 2014-07-24 09:27:29 UTC (rev 187)
@@ -133,7 +133,7 @@
* @throws Exception
* @return mixed
*
- * @deprecated use EntityManager::transactional() instead
+ * @deprecated use EntityManagerHolder::transactional() instead
*/
public function doInTransaction($func) {
$this->getLog()->info('Begin transaction.');
Modified: trunk/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php
===================================================================
--- trunk/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php 2014-07-23 18:12:43 UTC (rev 186)
+++ trunk/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php 2014-07-24 09:27:29 UTC (rev 187)
@@ -43,4 +43,16 @@
public function setEntityManager(EntityManager $entityManager) {
$this->entityManager = $entityManager;
}
+
+ /**
+ * Convenience wrapper around EntityManager::transactional()
+ * @param callable $callback
+ * @return mixed
+ */
+ public function transactional(callable $callback) {
+ $that = $this;
+ return $this->getEntityManager()->transactional(function (EntityManager $em) use ($callback, $that) {
+ return $callback($that);
+ });
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|