The NestedMatcher architecture was deliberately intended as a step along a road, but not the final implementation. It has some known issues (e.g.), and a lot of moving parts. It also doesn't inherit much functionality from Symfony, just the interface models. But that's OK, because that's all we wanted it to be.
In collaboration with David Buckmann (dbu) of Symfony CMF, we have overhauled the Symfony CMF Routing component to build it around the NestedMatcher design. That has been greatly refined, however. Most of the heavy lifting is now done by the CMF Routing component, and we're just filling in a few pieces.
This patch adds the CMF Routing component via Composer, and then leverages it. In short, the new design is:
ChainRouter: Chains together multiple routers (a matcher and a generator combined).
NestedMatcher: Evolved version of the old NestedMatcher
RouteProvider: More generalized version of InitialMatcher, now can be used by the Generator, too.
RouteFilter: Formerly Partial Matcher. Same basic idea.
FinalMatcher: same as before.
Route Enhancers: A new thing from CMF, lets us process the attributes array before it gets added to the request attributes Bag. I'm not using it yet, but this seems like it would be an even better place to put parameter upcasting than what we're working on in .
Generator: Right now we're just using the vanilla RouteProvider-backed Generator from CMF, which actually works fine.
Also, CMF (and therefore we) are using a thin wrapper around Symfony's UrlMatcher as the final matcher. What that means is most of our partial matchers go away, because they just duplicate what is already in that class. In fact, UrlMatcher already did more than we were, which means this patch immediately gets us:
- Matching by scheme (http vs. https)
- Matching by domain
Neither of which we had before. It also eliminates the need for the separate partial matcher for HTTP method. We still have a route filter for mime type, but if mime type-based matching ever integrates into UrlMatcher (as various people are, slowly, working on), then we can drop ours and inherit the Symfony one with no extra effort.
I also ended up merging our route compiler with Symfony's route compiler. It's a big ugly, but that's because Symfony's route compiler is not designed to be extended. That could be made cleaner if someone wants to tidy up Symfony's route compiler, but it's not a priority at the moment.
The patch looks large, but that's mostly because of removing lots of files and adding the CMF component. The net impact is about half as much Drupal-specific code in /core, which is a good thing.
- I need to add some caching and integrate with the path alias system, although this is stable as is.
- I don't know if we want to go all the way to integrating url and l into the generator now, or save for another patch. Input from committers welcome.
- New version ofthat uses Route Enhancers, as a separate patch.
User interface changes
None. This is mostly just code reorganization.
Very minor. The only one of note for most people is that there are no more "partial matchers". They're now called Route Filters, and we need fewer of them.
|PASSED: [[SimpleTest]]: [MySQL] 50,607 pass(es).|
|PASSED: [[SimpleTest]]: [MySQL] 49,684 pass(es).|
|PASSED: [[SimpleTest]]: [MySQL] 50,536 pass(es).|
|FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1874500-routing-take-2_4.patch. Unable to apply patch. See the log in the details link for more information.|
|PASSED: [[SimpleTest]]: [MySQL] 50,506 pass(es).|