-
Notifications
You must be signed in to change notification settings - Fork 11.4k
[10.x] Named static methods for middleware #46362
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
Conversation
13be1eb
to
5a870cc
Compare
c701783
to
dc484c8
Compare
@@ -63,7 +77,7 @@ public function handle($request, Closure $next, $redirectToRoute = null, $passwo | |||
} | |||
|
|||
return $this->responseFactory->redirectGuest( | |||
$this->urlGenerator->route($redirectToRoute ?? 'password.confirm') | |||
$this->urlGenerator->route($redirectToRoute ?: 'password.confirm') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$redirectToRoute
may be null
if no arguments, but it may also be an empty string when only passwordTimeoutSeconds
is specified.
"password.confirm:,300"
// or with this new syntax
RequirePassword::using(passwordTimeoutSeconds: 300);
dc484c8
to
8d7ec88
Compare
I feel that
Also, I think middleware aliases have their place, especially for simple middleware with few or no parameters. |
I would suggest naming the I think this functionality should either be implemented in a base middleware class which all middleware should extend or a trait like the original package, this will be helpful when creating for custom middleware with the |
After taking a beat, I think I could get behind I don’t think it makes sense to put this in a base class / trait for what we are trying to achieve. You lose named parameters, which is a nice feature of this, and then you’d have to have a method docblock for each middleware anyway to specify the parameters / types etc. |
I've renamed |
* wip * Standardise of `using` for Authorization middleware * Update ValidateSignature.php * Update ThrottleRequests.php * Update ThrottleRequests.php * Update RequirePassword.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
Continuation of #46219. Framework first version of "HasParameters".
This PR introduces a more "typed" API for all the first party middleware - which gives a nicer DX than the "stringy" API, in my opinion.
If we made this the documented approach, we could potentially remove the middleware aliases from the kernel.
https://github.com/laravel/laravel/blob/5070934fc5fb8bea7a4c8eca44a6b0bd59571be7/app/Http/Kernel.php#L48-L66