-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] add can
to the accessor prefixes recognized by the AttributeLoader
#61023
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
base: 7.4
Are you sure you want to change the base?
Conversation
…he AttributeLoader The ObjectNormalizer already recognizes `canX` as an accessor and "generates" a property for that, the AttributeLoader does not, so #[Ignore] attributes on `canX` are ignored, the return value is encoded in the normalized data. We just add the `can` prefix ot the list of accepted accessor prefixes, so the AttributeLoader now also recognized these.
This comment has been minimized.
This comment has been minimized.
can
to the accessor prefixes recognized by the AttributeLoadercan
to the accessor prefixes recognized by the AttributeLoader
can
to the accessor prefixes recognized by the AttributeLoadercan
to the accessor prefixes recognized by the AttributeLoader
#[Ignore] | ||
public function getSomethingElse(): int | ||
{ | ||
return 42; | ||
} |
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.
This additional test case seems not related to your PR topic. Is there a use for it that I've missed?
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.
I wanted to check the behaviour for getX
and make sure it keeps working after my change.
If you want me to remove it, I can do that.
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.
As it seems already covered by getIgnored2
, I think you can remove it.
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.
ignored2
is itself a property, I wanted to make sure it also works if its just the accessor, without any obvious property backing it. But I'll remove it.
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.
Can you please add a line to the changelog file of the component?
@nicolas-grekas like this? |
* Add support for `can*()` methods to `AttributeLoader` | ||
|
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.
* Add support for `can*()` methods to `AttributeLoader` | |
* Add support for `can*()` methods to `AttributeLoader` |
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.
🤦 yes, sorry. fixed that.
c33db1d
to
2003146
Compare
2003146
to
2d7a3fb
Compare
Would it make sense to backport this to 7.3, 7.2 and 6.4, or would that be to big of a BC break? |
New features are never backported in patch versions. |
Okay, so this counts as a new feature, not a bug fix? Good to know, so we'll need to wait for 7.4 to remove our work around! Thanks! |
can
to the accessor prefixes recognized by the AttributeLoadercan
to the accessor prefixes recognized by the AttributeLoader
The ObjectNormalizer already recognizes
canX
as an accessor and "generates" a property for that, the AttributeLoader does not, so #[Ignore] attributes oncanX
are ignored, the return value is encoded in the normalized data.We just add the
can
prefix ot the list of accepted accessor prefixes, so the AttributeLoader now also recognized these.I adapted a test that seemd to me to fit the best. If you'd prefer a dedicated test for that, I can do that, too.