Commit 13f009ec authored by Mathieu Rochette's avatar Mathieu Rochette Committed by Mathieu Rochette

return result from Doctrine\DBAL\Connection::transactional()

parent 4ec16d06
......@@ -1093,7 +1093,7 @@ class Connection implements DriverConnection
*
* @param \Closure $func The function to execute transactionally.
*
* @return void
* @return mixed The value returned by $func
*
* @throws \Exception
*/
......@@ -1101,8 +1101,9 @@ class Connection implements DriverConnection
{
$this->beginTransaction();
try {
$func($this);
$res = $func($this);
$this->commit();
return $res;
} catch (Exception $e) {
$this->rollBack();
throw $e;
......
......@@ -209,6 +209,14 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
});
}
public function testTransactionalReturnValue()
{
$res = $this->_conn->transactional(function($conn) {
return 42;
});
$this->assertEquals(42, $res);
}
/**
* Tests that the quote function accepts DBAL and PDO types.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment