-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyAccess] PropertyPath read/write property with __call #4683
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
Comments
@fabpot @bschussek do you want a PR for this ? |
I don't know how it would work in a sane way. You can work on a PR though but I'm not convinced it is a good idea. |
I'm not convinced this is a good idea either. Do you mean that the name of the searched setter method should be passed to This definitely shouldn't go into 2.1 anymore. |
the PropertyPath try to find a valid getter setter, in case it can't find it and there is a __call method, we could give a try by calling the default getter/setter maybe this could be configurable (if we want the __call fallback or not) |
I'm very much in favor of this, so I'll try to make a case for it. Using __call() for getters and setters makes sense for people who:
Under these conditions, __call() becomes a great way to reduce boilerplate. But if the PropertyPath doesn't support it, then using it in many places (notably most model classes) becomes impossible. Given that PropertyPath would be at a point where it has to throw an Exception anyway, I also see little downside to this. |
I agree with ethanresnick. This would be very useful. |
I'll work on this if it is not tackled by mid January. I am uber busy until then. |
@bschussek now that the |
@jaugustin You can add the functionality to the base $accessor = PropertyAccess::getPropertyAccessorBuilder()
->enableMagicCall()
//->disableMagicCall()
->getPropertyAccessor(); |
@bschussek ok I will work on a PR |
add a new propertyAccessorBuilder to enable / disable the use of __call by the PropertyAccessor
This PR was merged into the master branch. Discussion ---------- [PropertyAccess] add support for magic call Hi, I add support for magic call with the `PropertyAccess` the is basic implementation, if no `getter`, `isser`, or `hasser` or `_get` is found and there is `__call` then the PropertyAccess call the getter the same for setter. This functionality is disable by default | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | seems OK (failure/errors are the same on master) | Fixed tickets | #4683, #6413, #5309 | License | MIT | Doc PR | symfony/symfony-docs#2472 - [x] submit changes to the documentation @bschussek is this ok ? Commits ------- a785baa [PropertyAccess] add support for magic call, related to #4683
Hi,
PropertyPath doesn't read or write object's properties that are handle with a
__call
method.Propel has a delegation behavior, that delegate setter/getter with
__call
,@bschussek , @fabpot what do you think about that ?
I can provide a PR.
cc @willdurand
The text was updated successfully, but these errors were encountered: