-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
Add a new AccessType to allow for __call() #104
Comments
I would use a new property metadata class, but how would you define these properties? On the class level? Or do you still have them as real properties in your class? |
I still think this is a neat idea, but for my current project I've decided to use traditional getters and setters. When I was doing this, my properties were real properties in order to be persistable by Doctrine. Thanks! |
I'm closing this for now until someone needs it. |
Potential fix for "recursion detected" issue
I need it. |
Me too. We have a few things that need to be done on all get calls. Without __get support, we need to write the same 2 lines on >50 getters. This could easily be handled by a single __get() and __set() in the appropriate superclass |
+1 |
I need it. A have the same problem on several projects. |
It's also interresting with Doctrine Behaviors translatable where some methods are available using public function __call($method, $arguments)
{
return $this->proxyCurrentLocaleTranslation($method, $arguments);
} |
This fix do serializer more simple and usable :) without reflection. You can use any name for fields but set getters and setters in config. evgemar/serializer@13184a0 P.S. it is working with Propel too, not only with Doctrine ;) |
I've created an entity that uses __get() and __set() for access while still keeping properties protected for Doctrine. I've also implemented __call() to allow for more traditional-looking getters and setters, but JMSSerializerBundle can only use reflection (which bypasses my __get() implementation) or existing public methods. If there were another AccessType like "magic_call" it would be compatible with PHP's magic methods. For the moment I've overwritten the setAccessor() method on PropertyMetadata to avoid the checks for method existence, but that's obviously not right.
If anyone's wondering why I still want my __get() call to fire when serialization occurs, I've created the ability to have an "optional" getter in case I need to modify the data on the way out, and I'd like JMSSerializerBundle to respect that. Something like this:
The text was updated successfully, but these errors were encountered: