-
Notifications
You must be signed in to change notification settings - Fork 11.5k
[12.x] Add maintenance mode facade for easier driver extension #56090
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
Thanks for submitting a PR! Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
$this->app->singleton(MaintenanceModeManager::class); | ||
$this->app->singleton('maintenance.manager', function ($app) { | ||
return new MaintenanceModeManager($app); | ||
}); |
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.
You don't need to assign it a string name that is different than the class name. This could be a breaking change. You can just keep using the class name as the binding name.
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.
@taylorotwell I was matching up how other managers and drivers are bound in the container here. The core aliases registered in Application
above ensure class names still work:
Before:
dump(resolve(\Illuminate\Foundation\MaintenanceModeManager::class)::class); // Illuminate\Foundation\MaintenanceModeManager
dump(resolve(\Illuminate\Contracts\Foundation\MaintenanceMode::class)::class); // Illuminate\Foundation\FileBasedMaintenanceMode
After:
dump(resolve(\Illuminate\Foundation\MaintenanceModeManager::class)::class); // Illuminate\Foundation\MaintenanceModeManager
dump(resolve(\Illuminate\Contracts\Foundation\MaintenanceMode::class)::class); // Illuminate\Foundation\FileBasedMaintenanceMode
Perhaps I've missed something though?
Have reverted the container binding changes here. Maybe they'd be acceptable for 13.x instead? |
…el#56090) * maintenance mode facade * alias in provider * fix bindings * fix cs * noop driver * different cs to pint * revert container binding changes
I was trying to register a new maintenance mode driver in my app, and noticed a paper cut.
This PR adds a facade for maintenance mode, so a new driver can be registered by doing:
Instead of having to retrieve the underlying manager class:
This matches up with elsewhere in Laravel, like
Mail::extend(...)
andStorage::extend(...)
.It also binds
maintenance
andmaintenance.manager
strings into the container, so they can be used to retrieve the current maintenance mode driver and manager, like other core dependencies. FQNs still work like before.