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

Integration Points - run-time exclusion checking #239

Closed
jmcclell opened this issue Feb 19, 2014 · 3 comments
Closed

Integration Points - run-time exclusion checking #239

jmcclell opened this issue Feb 19, 2014 · 3 comments

Comments

@jmcclell
Copy link

I (like many others) am using the serializer package in a Symfony2 library to create a RESTful API.

Everything works swimmingly well, but there is one requirement I have that I am not able to figure out. I need to be able to exclude (or, inversely, expose) fields based on whether or not the end user has access to them. In my case, this depends on a Symfony Security expression.

I am having a very difficult time figuring out the best way to integrate such functionality.

The events seem to allow me to add data or change the data, but by that point I don't see how I could skip fields entirely. Even if I could, I don't see how I would be able to configure which fields should stay or go as there is no way to extend the property metadata with custom attributes. (That I can tell, anyway!)

Handlers don't work as they are just not meant for such a thing.

I have been running into road blocks trying to come up with a fairly elegant way of doing it, but the serializer codebase is still pretty foreign to me so I am just not seeing an easy path.

Does anyone have any recommendations? Or recommended ways that the codebase could be modified to provide greater extensibility? I'd be happy to take a crack at something along those lines if I knew I was headed in a feasible direction.

@stof
Copy link
Contributor

stof commented Feb 19, 2014

The library already has exclusion stategies. All you need to do is implement a custom one for your needs

@schmittjoh
Copy link
Owner

I'd recommend to ask such questions on stackoverflow. That's usually better and you get more answers.

@jmcclell
Copy link
Author

Of course. Thanks guys, I had tried SO prior and was only pointed toward using groups. stof's suggestion points me in the right direction.

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

3 participants