Skip to content

Commit

Permalink
Fixed 506c1eb for Laravel 5.1 Support (barryvdh#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylernathanreed authored and barryvdh committed Jun 8, 2017
1 parent 1878ff7 commit 17afbae
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,45 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
\Illuminate\Database\Events\TransactionBeginning::class,
'connection.*.beganTransaction',
], function ($transaction) use ($queryCollector) {
$queryCollector->collectTransactionEvent('Begin Transaction', $transaction->connection);

// Laravel 5.2 changed the way some core events worked. We must account for
// the first argument being an "event object", where arguments are passed
// via object properties, instead of individual arguments.
if($transaction instanceof \Illuminate\Database\Events\TransactionBeginning) {
$connection = $transaction->connection;
} else {
$connection = $transaction;
}

$queryCollector->collectTransactionEvent('Begin Transaction', $connection);
});

$db->getEventDispatcher()->listen([
\Illuminate\Database\Events\TransactionCommitted::class,
'connection.*.committed',
], function ($transaction) use ($queryCollector) {
$queryCollector->collectTransactionEvent('Commit Transaction', $transaction->connection);

if($transaction instanceof \Illuminate\Database\Events\TransactionCommitted) {
$connection = $transaction->connection;
} else {
$connection = $transaction;
}

$queryCollector->collectTransactionEvent('Commit Transaction', $connection);
});

$db->getEventDispatcher()->listen([
\Illuminate\Database\Events\TransactionRolledBack::class,
'connection.*.rollingBack',
], function ($transaction) use ($queryCollector) {
$queryCollector->collectTransactionEvent('Rollback Transaction', $transaction->connection);

if($transaction instanceof \Illuminate\Database\Events\TransactionRolledBack) {
$connection = $transaction->connection;
} else {
$connection = $transaction;
}

$queryCollector->collectTransactionEvent('Rollback Transaction', $connection);
});
} catch (\Exception $e) {
$this->addThrowable(
Expand Down

0 comments on commit 17afbae

Please sign in to comment.