symfony/symfony — pull request #5895 by Tobion (2012-11-02 11:53:09+00:00)
Title: [RFC][Routing] made generator and matcher independent from RequestContext

tests pass: yes
bc break: not really

After discussion with @crell, we agreed that the RequestContext is a burden in reusing the routing component. That's because it only duplicates information of the Request and is not really useful without it anyway. Since we probably cannot remove it fully as it would be a big BC break, my idea is to make it optional. So the symfony generator and matcher both work with a RequestContext and a Request. I removed the RequestContextAwareInterface from the interfaces so a custom router does not need a RequestContext anymore. The default symfony generator/matcher still implements RequestContextAwareInterface but can also work with a Request. So `UrlMatcher::match(Request)` is now also possible. And the generator can use `UrlGenerator::setRequest()` instead of `setContext()`.

I think it makes the routing more useable in symfony and more reusable for other libraries.
And it will probably make it easier to integrate content negotiation as matching a request directly with all it's metadata (like Accept header) is now possible.

One more point: symfony allowed to use matching a Request with #4363. But it's not integrated in symfony as symfonys router does not use it at all. So this PR could replace the other extension point.

There should be no real bc break. But people should be aware that RequestContextAwareInterface is not part of UrlGeneratorInterface/UrlMatcherInterface/RouterInterface anymore.