[SecurityBundle] Configure Voter priority via getDefaultPriority
| Q | A |
|---|---|
| Branch? | 6.2 |
| Bug fix? | no |
| New feature? | yes |
| Deprecations? | no |
| Tickets | Fix #43074 |
| License | MIT |
| Doc PR | Will do if PR gets approval |
The issue describes well the missing feature. Solution is based on https://github.com/symfony/symfony/issues/43074#issuecomment-998045430 As mentioned in https://github.com/symfony/symfony/issues/43074#issuecomment-1050070069 it can be solved with PHP attributes already. If this became obsolete, feel free to close it.
Hey!
I think @NicoHaase has recently worked with this code. Maybe they can help review this?
Cheers!
Carsonbot
We can also use #[Autoconfigure(tags: [['security.voter' => ['priority' => 3000]]])] but what about adding a #[AsVoter(priority: 3000)] attribute to make it easier ?
I like this proposal about #[AsVoter] actually. Would you be up to give it a try?
I feel like we could even deprecate these static methods in favor of attributes now.
Oh, reading the source, I figured out we already have an attribute for that: #[AsTaggedItem(priority: 100)] would work equally well.
Can you update the PR and its test cases to use+mention this attribute instead of getDefaultPriority()? I'm going to suggest deprecating this method in a follow up PR.
Friendly ping @paradajozsef