Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 9, 2020
1 parent af64f02 commit fa34d93
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Illuminate/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,9 @@ protected function createClassCallable($listener)

$listener = $this->container->make($class);

if ($listener->dispatchAfterCommit ?? null &&
$this->container->bound('db.transactions')) {
return $this->createCallbackForListenerRunningAfterCommits($listener, $method);
}

return [$listener, $method];
return $this->handlerShouldBeDispatchedAfterDatabaseTransactions($listener)
? $this->createCallbackForListenerRunningAfterCommits($listener, $method)
: [$listener, $method];
}

/**
Expand Down Expand Up @@ -490,6 +487,17 @@ protected function createQueuedHandlerCallable($class, $method)
};
}

/**
* Determine if the given event handler should be dispatched after all database transactions have committed.
*
* @param mixed $listener
* @return bool
*/
protected function handlerShouldBeDispatchedAfterDatabaseTransactions($listener)
{
return ($listener->dispatchAfterCommit ?? null) && $this->container->bound('db.transactions');
}

/**
* Create a callable for dispatching a listener after database transactions.
*
Expand Down

0 comments on commit fa34d93

Please sign in to comment.