Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Improve the way we append parent object if any #6171
Improve the way we append parent object if any #6171
Changes from all commits
c50c60a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Hi, @VincentLanglet There is BC break here.
In case of a create form in a subadmin, the parent is not anymore associated.
In my case, to workaround it, I need to associate the parent entity in the subAdmin::preCreate.
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.
Can you create an issue with as much information as you have.
Or directly create the PR to call
appendParentObject
if needed and explain why ?I called
appendParentObject
directly ingetNewInstance
which should be enough IMO, do you override this method ? @Kal74There 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.
Right, I overrided the getNewInstance!
Thanks.
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.
Do you need this method or can you make it private
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 don't need it.
But since it's called in the
getNewInstance
and I know some users are overridden this method (maybe without calling the parent method), I was thinking it could be useful to expose theappendParentObject
method.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
This fails with embedded documents (MongoDB) when adding new document (let's say it's called
Level2NestedDoc
) at 2nd level of nesting:Class "App\Document\Level1NestedDoc" does not have an identifier
.Maybe nesting such deep is not a good design (isn't it OK-ish with MongoDB's embedded documents?), but it worked on Sonata Admin v.3.
Now, after update to v.4, to work around the issue we have to override
AbstractAdmin::createNewInstance()
to omit this method's call. But maybe instead we couldembedded
flag, and/orWhat do you think? Should I open an issue?
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.
Better open an issue, this PR is 2 years old.
But, we won't check embedded in SonataAdmin since it's not related to any persistence bundle.
getObject is doing
Where does come from the Exception ?
If it's in the
call, we could add some check in https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/blob/4.x/src/Model/ModelManager.php
But its weird to have an entity without identifier, since all the admin (and parent admin) are supposed to be related to an entity/document.
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 There is BC break here, parent object is set to new instance instead of adding new instance to parent collection, and this does not work for 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.
That's intended, to solve #6166
And it works well for me since month.
If you think a special case is missed create an issue with a precise description.
But without any information, I would say that your setter or mapping has something wrong.