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
Fix editable relation on list #4992
Conversation
@jordisala1991 it does. |
@@ -89,6 +86,11 @@ public function getEnabled() | |||
} | |||
} | |||
|
|||
interface ModelManagerTest extends ModelManagerInterface |
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.
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.
Fixing the initial issue would be possible by introducing an interface very much like this one and have all model managers implement it in addition to the original one. None of this would be a BC break. The only issue would be finding a good name.
84f801f
to
327fc43
Compare
/** | ||
* @author Jordi Sala <jordism91@gmail.com> | ||
*/ | ||
interface DoctrineAwareManagerInterface |
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.
WDYT about this interface @greg0ire ?
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 find it weird that it seems to be used only in tests, and I have a bad feeling about this dependency on Doctrine. Maybe it is a necessary evil
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.
the only alternative to me is to add those methods to the modelManager interface on next major, and use the dirty trick I had before on tests. I guess this is not the only place where this happens.
My plan if we accept this new interface is to provide PRs to the persistence bundles to implement this interface.
There is always another alternative, but implies we remove the if check that uses the metadata. If I remove that, I won’t need the interface.
None of those solutions seems perfect to me. To be honest, the dirty trick didnt seem a super bad option, because it gives some space to do it better in the future, introducing a new interface gives more constraints.
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.
Yeah I can't think of anything better either. @sonata-project/contributors, should we accept this interface or remove the code that uses it?
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 will try what happens with and without that check first
6c82c07
to
1654265
Compare
1654265
to
f3ceb51
Compare
After some thought and testing, I think I found a solution that does not need to use the metadata class. Can you review again @sonata-project/contributors ? In this solution we rely on the |
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.
Great solution!
Please amend your commit message to explain what was broken and why your changes fix the issue. |
Isn't it better to change the message when squashing on merge? This could be the message:
Wdyt? can you add this message on merge? |
I'm fine with both solutions. I changed the subject to reflect what you did, as opposed to the side effect it had (fixing #818), and slightly altered the body. Thanks for this fix! |
Thank you @greg0ire |
getManagerType() returns "orm" while the entity manager is "doctrine_orm". Also this forces us to add doctrine code on the admin-bundle, while it should not know anything about the persistence layer (that's why we use "doctrine-orm-admin-bundle") The chosen solution is to not check on the metadata for the entity, but instead look at the fieldDescription, because it contains information about the field, like the "targetEntity" in case of a relation. Fixes sonata-project#818
I am targeting this branch, because this is BC.
Closes sonata-project/SonataDoctrineORMAdminBundle#818
Changelog
To do
Subject
getManagerType does not return what was expected, also if this method works it is better since it does not rely on container, but on properties that are already loaded.
This is a bugfix from my previous PR: #4930
Please, can you check if this works @mikemix ?