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

Setter property not found #654

Closed
guiyomh opened this issue Dec 13, 2016 · 2 comments
Closed

Setter property not found #654

guiyomh opened this issue Dec 13, 2016 · 2 comments
Labels

Comments

@guiyomh
Copy link

guiyomh commented Dec 13, 2016

Hi all,

i use nelmio/alice:^3.0@beta to run with Symfony 3.2. But i have a pb with setter on OneToMany relation.

image

It is a bug ? Or it's me , i do something bad ?

@theofidry
Copy link
Member

Hm hard to tell, I would expect it to work. I would recommend you to try debuging the PropertyHydrator, it's using Symfony PropertyAccess under the hood

@theofidry
Copy link
Member

theofidry commented Dec 16, 2016

nevermind the problem is that you have society: '<numberBeetween(1, 3)x @society, so you get an array of Society. The Symfony PropertyAccess will not iterate over your collection to do X calls of addSociety() but expects to find a setSocieties() instead.

I can only suggest you the following:

  • Add a method setSocieties()
  • Register a custom hydrator (you just need to decorate the existing property hydrator and do what you want in some cases and using the decorated one in the other)

I thought of adding support for it at some point, but it comes with with a performance cost for something that requires domain knowledge and can be easily fixed. If you feel strongly about it, you may still try a PR and show a blackfire profile, if the diff is not big, I'll gladly accept it.

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

No branches or pull requests

2 participants