Support for doctrine's orm embedded #1509
Draft
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.
Doctrine Embedded
This is a draft I have been sitting on for while using it in personal projects that could fix #866, which is a continuation/alternative suggestion for what was talked about in #350
For now I am looking for some feedback on my approach by people with a broader understanding of the bundle to check if this can move forward or there might be some blockers on the way since I only use the bundle for some basic image uploads.
How it's used
The general principle in both triggered from the listener (just Metadata/Driver/AnnotationDriver) and asset helper is that this traverses objects up towards the nearest non embeddable and use that as a property path. These can then be
used as e.g.
vich_uploader_asset(promotion, 'images.banners.largeRectangle')I made a small SF test project for this PR since my projects where I have used it aren't public at https://github.com/jennevdmeer/vich-uploader-embeddable-test
The entity/embeddables are not really anything new, the only thing to keep in mind is that the entity and the embeddables both need the
Vich/Uploadablemarking. See my test project entity. And the two embeddables; child, grandchild examples.The form types (example) work as you would expect with nested objects and do not change.
What works
VichImageTypeandVichFileTypeform typeKnown issues
Each embeddable entity should have its own modified at to trigger the listener as is already the case and described on https://github.com/dustin10/VichUploaderBundle/blob/master/docs/usage.md#step-2-link-the-upload-mapping-to-an-entity / Upload is not performed if there is no change in the entity #297
But since embeddables have no reference to its parent you can not change a property there from the setters in the embeddable classes.
Not looked at yet
#[ORM\Embedded(class: 'Vich\UploaderBundle\Entity\File')];