Problem/Motivation
Since #3311365: Use PHP attributes for route discovery there are three routing events: STATIC, DYNAMIC and ALTER.
YamlRouteDiscovery listens for STATIC, which adds routes in *.routing.yml files and also invokes any route_callbacks defined in the YAML.
RouteSubscriberBase only listens for ALTER.
Similar to how #3421573: Convert permission providers to tagged services; unify with a service locator allows permission providers to become services, we could allow route_callbacks to easily become event subscriber services by allowing RouteSubscriberBase to listen on STATIC (and perhaps DYNAMIC) as well.
Steps to reproduce
Proposed resolution
Add another event subscriber method to RouteSubscriberBase.
Make RouteSubscriberBase::alterRoutes() a no-op default implementation instead of abstract.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3593789
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
longwaveAlongside #3593666: Convert Views routes to attributes this will allow us to drop views.routing.yml, for example.
Comment #3
longwaveComment #5
smustgrave commentedCame here from #3593666: Convert Views routes to attributes and was about to ask what can we do for the route.callback and you were 2 steps ahead.
This looks good!
Comment #6
godotislateThis needs a CR for how to convert the route_callbacks and the new method in RouteSubscriberBase (maybe also that
alterRoutes()isn't abstract anymore, though I'm not sure that changes much for developers?)Also looks like this a dupe of #3584791: Convert route callbacks to event subscribers. Probably can close that one since this is further along.