Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Fix for nested transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
sharifzadesina authored May 5, 2020
1 parent 188ed4d commit c3fa236
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/TransactionalDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,19 @@ protected function onTransactionCommit()
{
$transaction = array_pop($this->transactions);

// we don't have any transaction handled
if (null === $transaction) {
return;
}

$last = Arr::last($this->transactions);

// if there is another parent transaction, just add events to it
if (null !== $last) {
$last->events = array_merge($last->events, $transaction->events);
return;
}

foreach ($transaction->events as $args) {
$this->dispatcher->dispatch(...$args);
}
Expand Down

0 comments on commit c3fa236

Please sign in to comment.