symfony icon indicating copy to clipboard operation
symfony copied to clipboard

[SecurityBundle] Configure Voter priority via getDefaultPriority

Open paradajozsef opened this issue 3 years ago • 4 comments

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.

paradajozsef avatar Jun 02 '22 21:06 paradajozsef

Hey!

I think @NicoHaase has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

carsonbot avatar Jun 03 '22 17:06 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.

nicolas-grekas avatar Jul 28 '22 13:07 nicolas-grekas

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.

nicolas-grekas avatar Jul 28 '22 13:07 nicolas-grekas

Friendly ping @paradajozsef

nicolas-grekas avatar Oct 19 '22 12:10 nicolas-grekas