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

Command icon 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

longwave created an issue. See original summary.

longwave’s picture

Alongside #3593666: Convert Views routes to attributes this will allow us to drop views.routing.yml, for example.

longwave’s picture

Status: Active » Needs review

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Came 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!

godotislate’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

This 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.