manager_name = $manager_name; } /** * Execute a Closure within a transaction. * * @param Closure $callback * @return mixed * * @throws \Exception */ public function transaction(Closure $callback) { $em = Registry::getManager($this->manager_name); $con = $em->getConnection(); try { $con->beginTransaction(); // suspend auto-commit $result = $callback($this); $em->flush(); $con->commit(); } catch (\Exception $e) { $con->rollBack(); throw $e; } return $result; } }