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

Obtain VirtualProperty value using a service #359

Closed
piotaixr opened this issue Oct 31, 2014 · 0 comments · Fixed by #708
Closed

Obtain VirtualProperty value using a service #359

piotaixr opened this issue Oct 31, 2014 · 0 comments · Fixed by #708

Comments

@piotaixr
Copy link

Hi.

I am currently looking for a way to add properties to a serialized object depending on some computation done by a service in my application.

The only way I see to do that is to use a SerializerListener and, when to serialized object has the correct class, add the data.
If you have to do that for only one or two classes, fine, but if it is not the case, you will have to add a lot of different listeners that will be called for each serialized object (if I am not mistaken).

The other way I see that, is by using a virtual property, but if the computation is done by a service, the only way to have this working is to inject the service in my doctrine entity which is quite ugly too...

I was wondering if it was possible to add some parameters to the VirtualProperty annotation (property name + service name + method name) to be able to use a service to get the value of a virtual property of a class.

What do you think about that?
If this feature is interesting you, I can try to implement it (i'll eventually need some advice on what to do to have it work correctly).

EDIT: i just submitted that and noticed that it is more about the serializerbundle than the serializer component itself :S

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

Successfully merging a pull request may close this issue.

1 participant