Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel] Add the UidValueResolver argument value resolver#44665
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| useSymfony\Component\Uid\UuidV4; | ||
| useSymfony\Component\Uid\UuidV6; | ||
| class UidController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Check this file for different use cases.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
0188adb to6712733CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
aurimasniekis commentedDec 17, 2021
Nice, I was just thinking of making something like this 👍 I am just trying to figure out now how is the best way to make route parameter requirements based on Uid |
b2c1b7f tofd22d35CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
...mfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/UidController.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
nicolas-grekas commentedDec 17, 2021
That's a good question actually. If we figure out how to make this, we might be able to remove the proposed Any idea how to do this? |
nicolas-grekas commentedDec 17, 2021
Now I'm wondering: what about removing the "format" configuration setting and attribute, and instead accept only the canonical representation? |
aurimasniekis commentedDec 17, 2021
I haven't yet looked into the router, but I am wondering is there some kind of parser level for parameters before generating URL matchers? If so we could add some extension in that point which would mark that param as UID |
nicolas-grekas commentedDec 17, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
We could define a If this looks like a useful path forward, we could then simplify this PR and make the resolver accept any format. I think that's my current preference (and we could define these |
aurimasniekis commentedDec 17, 2021
My previous implementation was basically like you mention parameter + argument resolver, but I was planning to look into something nicer |
49c3f64 to4b61f8eCompareUh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Uid/Tests/ArgumentResolver/UidValueResolverTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
11ef7d9 to785c6efComparenicolas-grekas commentedFeb 24, 2022
Thank you@fancyweb. |
…egular-expressions constants to use as route parameter requirements (fancyweb)This PR was merged into the 6.1 branch.Discussion----------[Routing] Add Requirement, a collection of universal regular-expressions constants to use as route parameter requirements| Q | A| ------------- | ---| Branch? | 6.1| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets | -| License | MIT| Doc PR | -Ref#44665.We need a way to easily reference some universal complicated regexes in routes parameters requirements, for example:```php#[Route(path: '/users/{id}', requirements: ['id' => Requirement::UUID])]#[Route(path: '/users/{id<'.Requirement::UID_BASE58.'>}')]```What about having a collection in the routing component itself? I'm sure there are other common cases we would add here.Commits-------f49cb6a [Routing] Add Requirement, a collection of universal regular-expression constants to use as route parameter requirements
Uh oh!
There was an error while loading.Please reload this page.
This feature adds an argument value resolver for UIDs.
Before:
After:
By default, all formats are accepted because the resolver uses the
fromString()method from the target UID class.It's possible to restrict to one format or a combination of formats by using a route parameter requirement, for example: