Add Application::removeDeferredServices method #53362
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
Application::removeDeferredServices()
method. TheApplication
class already has a series of methods for interacting with deferred services:getDeferredServices()
- Get all deferred servicessetDeferredServices(array $services)
- Overwrite all deferred servicesaddDeferredServices(array $services)
- Merge an array of services into the current deferred servicesisDeferredService(string $service)
- Determine if a service is deferredCurrently, if you wanted to remove a service from the deferred service list, you'd have to do something like so:
This is real code I currently have in a package. This PR adds what I consider to be a missing method, which replaces the above code with the following:
I appreciate that this is an obscure use case, but I figured it's worth a PR for such a simpler method with very little overhead and a tiny footprint.
From my use case, I'm providing a custom binding for
auth.password
andauth.password.broker
, which I'm aware will be hit before those deferred services are overridden. This is simply a way to tidy up, and prevent rare edge cases where they end up being loaded after I've overridden.