Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | no |
Symfony version | 3.3.6 |
I know the serializer is due for a redesign (#19330) but I'm daring to make a feature request for the time being. Currently (afaik) the mapping (yaml/xml/annotations) lack a way of ignoring attributes and you end up writing a normalizer to do just that.
With a bit of digging I figured it won't be too difficult to add an attribute metadata option to ignore the attribute (as is done for groups
and maxDepth
options). This can then be read by the (to be written) getIgnoredAttributes
getter to get the ignored attributes, instead of accessing the ignoredAttributes
array directly.
The ignored attribute is useful for classes that have no groups but want to exclude a property, say the id
property. It's cumbersome to add a group specifically to do that.
The YAML could look like this:
My\Fancy\Namespace\Entity\Alien:
attributes:
id:
ignore: true
Or to keep things clean:
My\Fancy\Namespace\Entity\Alien:
ignoredAttributes:
- id
Please share your thoughts as I'm willing to implement this π