Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Laravel container on private Router - closes #77 #78

Merged
merged 1 commit into from
Oct 13, 2022
Merged

Use Laravel container on private Router - closes #77 #78

merged 1 commit into from
Oct 13, 2022

Conversation

rodrigopedra
Copy link
Contributor

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:

$this->router->get($missingUrl, function () use ($redirects, $missingUrl) {
$redirectUrl = $this->determineRedirectUrl($redirects);
$statusCode = $this->determineRedirectStatusCode($redirects);
event(new RouteWasHit($redirectUrl, $missingUrl, $statusCode));
return redirect()->to(
$redirectUrl,
$statusCode
);
})->where('wildcard', '.*');
});

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.

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.
@rodrigopedra
Copy link
Contributor Author

ping @freekmurze

@freekmurze
Copy link
Member

Thanks!

@rodrigopedra rodrigopedra deleted the patch-1 branch October 13, 2022 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Laravel v9.33.0 not working
2 participants