Problem/Motivation
In the road of simplifying the routing system, I would like to propose another change.
Back in 2015 when we tried to get Drupal 8 out and routing was one of the major performance issues, we decided to move the routing system to become more lazy. One step of that was to introduce the idea of lazy route filters and enhancers, so services, which aren't loaded on every request.
There are a couple of problems with them though:
- Its hard to debug (you filter go to all route filters and then you do another loop)
- The priorities are not taken into account properly (they aren't shared between lazy and non lazy route filters)
- The additional layer of indirection is also potential a bit slower
Proposed resolution
- Make every route filter and enhancer "lazy"
- Make the router aware of the class resolver
- Inject all route filter/enhancer IDs into the router class.