Skip to content

Commit

Permalink
Fixes support with Laravel 10.30
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Dec 6, 2023
1 parent addf4fc commit 0c755d8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Events/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,30 @@ class EventServiceProvider extends ServiceProvider
public function register()
{
$this->app->singleton('events', function ($app) {
return (new Dispatcher($app))->setQueueResolver(function () use ($app) {
// return (new Dispatcher($app))->setQueueResolver(function () use ($app) {
// return $app->make(QueueFactoryContract::class);
// })->setTransactionManagerResolver(function () use ($app) {
// return $app->bound('db.transactions')
// ? $app->make('db.transactions')
// : null;
// });

// The following adds support for Laravel 10.30 when a transaction manager resolver
// was included as part of the dispatcher. Detect its presence and set it as needed
// @deprecated remove reflection and use code above in v4 (Laravel 11)
$dispatcher = (new Dispatcher($app))->setQueueResolver(function () use ($app) {
return $app->make(QueueFactoryContract::class);
});

if (method_exists($dispatcher, 'setTransactionManagerResolver')) {
$dispatcher->setTransactionManagerResolver(function () use ($app) {
return $app->bound('db.transactions')
? $app->make('db.transactions')
: null;
});
}

return $dispatcher;
});

$this->app->singleton('events.priority', function ($app) {
Expand Down

0 comments on commit 0c755d8

Please sign in to comment.