8000 make RequestContext optional in generator and matcher · Issue #8705 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
make RequestContext optional in generator and matcher #8705
Closed
@fabpot

Description

@fabpot

from #5895:

"
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. And the important interfaces like the RouterInterface required the RequestContext anyway. So there was no way to use Request matching without RequestContext. This PR replaces the other extension point.

The only bc break is in terms of interfaces. People should be aware that RequestContextAwareInterface is not part of UrlGeneratorInterface/UrlMatcherInterface/RouterInterface anymore. And the RequestMatcherInterface was changed.
"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0