Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] Extract request matchers for better reusability #47595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2022

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Sep 16, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets n/a
License MIT
Doc PR

The RequestMatcher class hardcodes its matchers. This PR extracts those into their own classes so that we can compose a RequestMatcher and allow better reusability.

@fabpot
Copy link
Member Author

fabpot commented Sep 16, 2022

I would love to simplify the RequestMatcher class by deprecating all the match* methods but I'm not sure it's worth it.

@fabpot fabpot force-pushed the request-matchers branch 2 times, most recently from b582774 to 1f853b2 Compare September 16, 2022 09:04
Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the class be renamed ChainRequestMatcher as of Sf 7.0 and/or add a @final?

@fabpot fabpot force-pushed the request-matchers branch 2 times, most recently from bcb1557 to 33f97a3 Compare September 16, 2022 16:17
@fabpot fabpot force-pushed the request-matchers branch 4 times, most recently from cc7b315 to e23feac Compare September 17, 2022 05:48
}

$container
->register($id, RequestMatcher::class)
->register($id, ChainRequestMatcher::class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
->register($id, ChainRequestMatcher::class)
$container->register($id, ChainRequestMatcher::class)

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep the current name: it doesn't have the same interface + needless BC break ahead when renaming.

@fabpot fabpot force-pushed the request-matchers branch 2 times, most recently from 0109fe9 to 961cd85 Compare September 17, 2022 11:59
@GromNaN
Copy link
Member

GromNaN commented Nov 24, 2022

I had to build a factory to create an instance of RequestMatcherInterface from an array of config, compatible with older and newer Symfony versions. If anybody have a similar needs, the code is here: https://gist.github.com/GromNaN/3ab352cc6bc348b8405e98006fcc2754

nicolas-grekas added a commit that referenced this pull request Jun 30, 2023
… behaviors (GromNaN)

This PR was squashed before being merged into the 7.0 branch.

Discussion
----------

[HttpFoundation] Remove deprecated classes, method and behaviors

| Q             | A
| ------------- | ---
| Branch?       | 7.0
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | n/a

Clean `symfony/http-foundation` from all its legacy.

- Remove `RequestMatcher` and `ExpressionRequestMatcher`,
  deprecated since #47595
- Remove `Request::getContentType()`,
  deprecated since #45034
- Throw a `UnexpectedValueException` or `BadRequestException` when `ParameterBag::filter()` or `InputBag::filter()` reads an invalid value and the flag `FILTER_NULL_ON_FAILURE` is not set.
  new behavior announced since #48525
- Throw a `InvalidArgumentException` when calling `Request::create()` with a malformed URI,
  deprecated since #49376

Commits
-------

665a775 [HttpFoundation] Remove deprecated classes, method and behaviors
OskarStark added a commit to symfony/symfony-docs that referenced this pull request Dec 21, 2023
This PR was squashed before being merged into the 7.0 branch.

Discussion
----------

[Security] Update request matcher doc

RequestMatcher class has been removed in 7.0 cf [code PR](symfony/symfony#47595)

Changing link and rewording according to new behaviour

Commits
-------

f32a8cf [Security] Update request matcher doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants