Skip to content

Conversation

@jennevdmeer
Copy link

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')

vich_uploader_asset

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/Uploadable marking. 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

  • (Recursive) embeddables
  • Using it with symfony forms
    • The VichImageType and VichFileType form type
    • The delete/download functionality in the default form template
      formtype
  • SF profiler mapping collector
    profiler

Known issues

Not looked at yet

  • Other configuration methods other than Attributes;
  • ODM Embedded (I only have MySQL set up and no other DB experience);
  • if it works together with the #[ORM\Embedded(class: 'Vich\UploaderBundle\Entity\File')];
  • any existing tests, or creating any new ones for this other than my basic sf demo project.

@jennevdmeer jennevdmeer changed the title Feature vich orm embedded Support for doctrine's orm embedded May 28, 2025
@jennevdmeer jennevdmeer marked this pull request as draft May 28, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

About UploadableField in a Doctrine Embeddable class

1 participant