Skip to content

Commit

Permalink
Use Laravel container on private Router - closes #77 (#78)
Browse files Browse the repository at this point in the history
closes #77

As the container parameter is nullable in `Illuminate\Routing\Router`'s constructor, an empty container is assigned in its constructor when no container is provided.

Since laravel/framework#44339 introduced `Illuminate/Routing/Contracts/CallableDispatcher`, a router needs this interface bound to dispatch closure bound routes such as the ones registered here:

https://github.com/spatie/laravel-missing-page-redirector/blob/ba2bc5f2e9cf3be883c311c125c756903eae412d/src/MissingPageRouter.php#L42-L53

This PR

- Passes Laravel Container to the `Router` constructor in this package's Service Provider, so it has a container which knows how to build a `CallableDispatcher` instance.
  • Loading branch information
rodrigopedra committed Oct 13, 2022
1 parent ba2bc5f commit cf93664
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/MissingPageRedirectorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function boot()
$this->app->bind(Redirector::class, config('missing-page-redirector.redirector'));

$this->app->bind(MissingPageRouter::class, function ($app) {
$router = new Router($app['events']);
$router = new Router($app['events'], $app);

$redirector = $app->make(Redirector::class);

Expand Down

0 comments on commit cf93664

Please sign in to comment.