[master] Add route removal functionality to RouteCollection #56055
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 a
remove()
method to theRouteCollection
andCompiledRouteCollection
classes, enabling the removal of previously defined routes. This is particularly useful for overriding or removing routes defined by third-party packages.Context
I had several cases where package-defined routes interfered with my application's use case or needed modification (changing middleware, etc.) without removing the package itself. This change enables such removal/overriding of routes defined by third-party packages.
Note
This is a breaking change as it adds a new method to the
RouteCollectionInterface
. I'm targeting the master branch but am open to targeting the 12.x branch if preferred.Further Discussion
Is there interest in extending this functionality to make it easier to modify existing routes (e.g., changing middleware)? One idea would be to add functionality to define a new route and remove the existing one in a single operation.