-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 accessor property instead of code #6837
Add accessor property instead of code #6837
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this work with a path? like
'accessor' => 'children.name'
Like it's implemented, no. We could add support for path, but:
Should I rename the option to |
I understand the idea, but I think that's unusual, what I would expect is to behave the same way that the form component does, some examples that I think they should work: ->add('address.name');
->add('addressName', null, ['accessor' => 'address.name']);
->add('firstAddressName', null, ['accessor' => 'addresses[0].name']);
->add('thumbnail', null, ['accessor' => 'image[thumbnail]']); |
Should we allow
|
@vladyslavstartsev I know you're using this property (or at least you tried). |
IMO |
but, since this option will void SRP, maybe it will be better to do, 2 separate options
WDYT? |
With two options we have to handle the case when both are set. I don't think it's again SRP, for instance symfony allow both a property path or a method for the |
The only things to decide here is Allowing Method + PropertyPath VS Allowing Method + Method name |
my vote is for |
Do you have examples in your code, where property path wouldn't work ? |
Since I don't have in mind (and this can still be done by passing the method), I allowed property path instead of method name @franmomu |
f91592e
to
fa7b65d
Compare
fa7b65d
to
aa75319
Compare
Sorry @dmaicher I forgot to update the doc ^^' |
Could you please rebase your PR and fix merge conflicts? |
2868774
to
bf83760
Compare
.' since sonata-project/admin-bundle 3.x and will throw an exception in 4.0.', | ||
\E_USER_DEPRECATED | ||
); | ||
@trigger_error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since code
is always set in the persistence bundles, this is always triggered: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/runs/1903176971?check_suite_focus=true#step:8:108
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove the code in the persistence bundle.
If the name is getfoo
and the fieldName
is bar
, because we're passing the code
, the value will be $object->getFoo()
instead of relying on bar
; this seems to be a bug to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@VincentLanglet I've got an issue because of this change. On PHP8 this gives me an error
EDIT: This is happening because the name of the field is also a function in PHP ( |
@toooni This should have been fixed by https://github.com/sonata-project/SonataAdminBundle/pull/6859/files Can you be more explicit ? |
@VincentLanglet Oh, sorry. I've updated the day before the fix. |
Subject
I am targeting this branch, because BC.
Closes #6831.
Closes #6741.
Changelog