Skip to content

Commit

Permalink
Fix dispatcher not registering when db is already resolved (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
John S Long authored and fntneves committed Aug 19, 2019
1 parent e1a9277 commit aa41f4e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Neves/Events/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function register()
return;
}

$this->app->afterResolving('db', function ($connectionResolver) {
$resolver = function () {
$eventDispatcher = $this->app->make(EventDispatcher::class);
$this->app->extend('events', function () use ($eventDispatcher) {
$dispatcher = new TransactionalDispatcher($eventDispatcher);
Expand All @@ -32,7 +32,13 @@ public function register()

return $dispatcher;
});
});
};

if ($this->app->resolved('db')) {
$resolver();
} else {
$this->app->afterResolving('db', $resolver);
}
}

/**
Expand Down

0 comments on commit aa41f4e

Please sign in to comment.