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

I want to configure the default exclution policy #65

Closed
Nyholm opened this issue Mar 25, 2013 · 3 comments
Closed

I want to configure the default exclution policy #65

Nyholm opened this issue Mar 25, 2013 · 3 comments

Comments

@Nyholm
Copy link
Contributor

Nyholm commented Mar 25, 2013

Is that feature of any interest? I want to have full control of what is going to be serialized.

@schmittjoh
Copy link
Owner

You can set your own exclusion policy already:

$serializer->serialize($data, 'json', SerializationContext::create()->setExclusionPolicy($yourPolicy));

@Nyholm
Copy link
Contributor Author

Nyholm commented Mar 26, 2013

I'm using this bundle with FosRestBundle. If I serialize an object and its referring objects I want to control what is being printed to the Rest clients. My current solution is to write @ExclusionPolicy("all") on each entity and then use @expose on the properties I want to expose.

The problem is when a developer forgets about the API and creates a new relation between two objects A and B where A is a part of the Rest API. Now will all properties of B be exposed.

Therefore I wish to have a setting in config.yml with the default exclusion policy. If I look at the driver (ie JMS\Serializer\Metadata\Driver\YamalDriver line 45) you have hard coded the exclusion policy to be 'NONE'.

I could make the change myself and do a pull request if you like.

@schmittjoh
Copy link
Owner

I see. This has been suggested before, see schmittjoh/JMSSerializerBundle#159

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

No branches or pull requests

2 participants