-
-
Notifications
You must be signed in to change notification settings - Fork 438
[Voter] [Normalizer] Turn off generated Voter and Normalizer by default, also fix failed test #416
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,10 +10,13 @@ class <?= $class_name ?> extends Voter | |
| { | ||
| protected function supports($attribute, $subject) | ||
| { | ||
| // replace with your own logic | ||
| // https://symfony.com/doc/current/security/voters.html | ||
| return in_array($attribute, ['POST_EDIT', 'POST_VIEW']) | ||
| && $subject instanceof \App\Entity\BlogPost; | ||
| // Replace with your own logic | ||
| // See https://symfony.com/doc/current/security/voters.html | ||
| // | ||
| // return in_array($attribute, ['POST_EDIT', 'POST_VIEW']) | ||
| // && $subject instanceof \App\Entity\YourEntity; | ||
|
|
||
| return false; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is better: the now commented line were fine uncommented, no? Because there is this line to remove now, this might confuse some. |
||
| } | ||
|
|
||
| protected function voteOnAttribute($attribute, $subject, TokenInterface $token) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,11 @@ public function normalize($object, $format = null, array $context = array()): ar | |
|
|
||
| public function supportsNormalization($data, $format = null): bool | ||
| { | ||
| return $data instanceof \App\Entity\BlogPost; | ||
| // Replace with your own logic | ||
| // See https://symfony.com/doc/current/serializer/custom_normalizer.html | ||
| // | ||
| // return $data instanceof \App\Entity\YourEntity; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same note as above, it'd make sense uncommenting this to me.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally agree, That's what I said in the previous PR.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. I agree. The current example code seems pretty clear, and it's better than needing to know to remove that
(if a non-FQN were passed, we'd look for it in WDYT? |
||
|
|
||
| return false; | ||
| } | ||
| } | ||
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.
Maybe replace POST by something else? It means "after" also, this can be confusing.
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.
Good catch. At the very least, we could change this to
BLOG_POST_EDIT... though there is also no rule that says that things need to be upper case...If we add a question about the entity/class, then we would derive this from the entity class name.