Skip to content

Commit

Permalink
Added explicit configuration methods to TransactionBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Aug 23, 2014
1 parent 6fa6002 commit a6985cb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 0 additions & 5 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
*/
class Connection implements DriverConnection
{
/**
* Constant for transaction isolation level configuration variable.
*/
const ISOLATION_LEVEL = 'dbal.isolation-level';

/**
* Constant for transaction isolation level READ UNCOMMITTED.
*/
Expand Down
16 changes: 14 additions & 2 deletions lib/Doctrine/DBAL/TransactionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
class TransactionBuilder
{
const ISOLATION_LEVEL = 'dbal.isolation-level';

/**
* The transaction manager.
*
Expand All @@ -32,20 +34,30 @@ public function __construct(TransactionManager $manager)
}

/**
* Sets the isolation level for this transaction.
* Sets a configuration variable.
*
* @param string $configurationName The configuration variable name.
* @param string $configurationValue The configuration value.
*
* @return \Doctrine\DBAL\TransactionBuilder The current instance for chaining.
*/
public function with($configurationName, $configurationValue)
protected function with($configurationName, $configurationValue)
{
$this->configuration[$configurationName] = $configurationValue;

return $this;
}

/**
* @param integer $isolationLevel
*
* @return \Doctrine\DBAL\TransactionBuilder
*/
public function withIsolationLevel($isolationLevel)
{
return $this->with(self::ISOLATION_LEVEL, $isolationLevel);
}

/**
* Begins the transaction and returns the associated Transaction object.
*
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/TransactionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function beginTransaction(array $configuration = array())
{
$this->connection->connect();

if (isset($configuration[Connection::ISOLATION_LEVEL])) {
$this->connection->setTransactionIsolation($configuration[Connection::ISOLATION_LEVEL]);
if (isset($configuration[TransactionBuilder::ISOLATION_LEVEL])) {
$this->connection->setTransactionIsolation($configuration[TransactionBuilder::ISOLATION_LEVEL]);
}

$transaction = new Transaction($this, $configuration);
Expand Down

0 comments on commit a6985cb

Please sign in to comment.