- 🇷🇴Romania amateescu
Wouldn't this reverse (part of) the effort to simplify the routing system? For example: #2883680: Force all route filters and route enhancers to be non-lazy →
Currently, during a request, Router::matchRequest() calls applyRouteEnhancers(), and every route enhancer is run on the route.
Core has 7 classes that implement EnhancerInterface, so that's not a big performance cost, but still, it means that on *every* request, EntityRouteEnhancer, say, has to check if the it applies to the route. And it's a performance cost that rises if contrib or custom code adds route enhancers.
But, EntityRouteEnhancer's check to see if it should act has nothing to do with the incoming request, and only looks at the route:
protected function applies(Route $route) {
return !$route->hasDefault('_controller') &&
($route->hasDefault('_entity_form')
|| $route->hasDefault('_entity_list')
|| $route->hasDefault('_entity_view')
);
}
That's also the case with all of core's route enhancers.
Add a method EnhancerInterface::appliesToRoute() to determine at compile time whether the enhancer applies to a route. The RouteBuilder then stores this value in the compiled route's options.
Then on request, Router::applyRouteEnhancers() runs only the enhancers that apply.
If there are any enhancers in contrib or custom code that determine whether they apply based on request values, they can simply return TRUE for appliesToRoute(), and that way they are always called for routes.
- add the method
- update core enhancers
- write tests
None.
New method on EnhancerInterface.
Active
10.1 ✨
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Wouldn't this reverse (part of) the effort to simplify the routing system? For example: #2883680: Force all route filters and route enhancers to be non-lazy →