Skip to content
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

[Improvement] Ability to define a global exclusion_policy: ALL for all classes. #1144

Closed
Yivan opened this issue Nov 29, 2019 · 4 comments
Closed

Comments

@Yivan
Copy link

Yivan commented Nov 29, 2019

Hello,

Actually we can only set exclusion_policy: ALL at the class level. When having many classes whith complexe inheritence (vendor package where we can not use annotation), the only way seems actually to create an class yml file for each classes and parent classes to set exclusion_policy: ALL.

This improvement is about adding a global parameters to the builder or context, which will set by exclusion_policy: ALL for all classes.

For instance something like:
$context->setExcludePolicyAll(true);
(like we have actually a global way to serialze null value: $context->setSerializeNull(true);)

Thanks

@goetas
Copy link
Collaborator

goetas commented Nov 29, 2019

Global settings have been discussed and dismissed in #1025 schmittjoh/JMSSerializerBundle#427 schmittjoh/JMSSerializerBundle#530

@Yivan
Copy link
Author

Yivan commented Nov 29, 2019

Thanks, I have read the discussion.

What i mean is not a global static one, maybe the title is wrong and should be changed.
But more a settings for the context in the actual run for serialization. So it want change other serailization call made by other bundles.
As we can set $context->setSerializeNull(true);, cannot we set something like $context->setExcludePolicyAll(true); ? I missed something ?

@goetas
Copy link
Collaborator

goetas commented Nov 29, 2019

the main reason for that is explained in schmittjoh/JMSSerializerBundle#427 (comment) (other projects can not generate metadata about serialized classes, and this library itself started to explore some ideas in #903, and context dependent configurations are a stil a problem)

setSerializeNull was implemented at the very beginning of the creation of this library... NULL handling is always tricky... so I do not know if it was a good idea or not...

@Yivan
Copy link
Author

Yivan commented Nov 29, 2019

Thanks, i understand better! This task can remain close so.
Best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants